为什么lxc在lxcwebpanel中的功能与预期一样,而不是在CLI或python中?

2024-04-18 21:19:43 发布

您现在位置:Python中文网/ 问答频道 /正文

观察结果

  1. lxc-webpanel函数如预期
  2. 从命令行界面发出的lxc命令,返回非零退出状态1
  3. 从python解释器中的lxclite模块调用的函数会引发异常

问题

我如何找到使lxc webpanel按预期运行的缺失因素?当我在bashshell中发出lxc命令时,或者当我从python解释器调用lxc webpanel相同的def时,lxc命令失败。在

目标

能够使用bashcli或python会话来管理lxc容器

系统信息

  • 没有LSB模块可用。在
  • 分发服务器ID:Ubuntu
  • 说明:Ubuntu 14.04.2 LTS
  • 发布日期:14.04
  • 代号:trusty
  • uname -r:3.13.0-35-powerpc64-smp

使用lxc webpanel创建了一个名为“test container”的容器。在

观察1:lxc webpanel试用截图

观察2:bash CLI中的lxc命令

  • 在:lxc-info -qn test-container

    输出:

test-container doesn't exist

  • {cd3}

    输出:

attach.c: lxc_attach: 635 failed to get the init pid

观察结果3:lxclite def call from ipython3

  • 在: import lxclite as lxc container = 'test-container' lxc.info(container)

ContainerDoesntExists Traceback (most recent call last) in () ----> 1 lxc.info(container)

../../python3_dev/_lxc/lxclite/init.py in info(container) 122 if not exists(container): 123 raise ContainerDoesntExists( --> 124 'Container {} does not exist!'.format(container)) 125 126 output = _run('lxc-info -qn {}|grep -i "State\|PID"'.format(container),

ContainerDoesntExists: Container test-container does not exist!

注意:lxc-checkconfig输出:

Kernel configuration not found at /proc/config.gz; searching...

Kernel configuration found at /boot/config-3.13.0-48-powerpc64-smp

--- Namespaces ---

Namespaces: [enabled]

Utsname namespace: [enabled]

Ipc namespace: [enabled]

Pid namespace: [enabled]

User namespace: [enabled]

Network namespace: [enabled]

Multiple /dev/pts instances: [enabled]

--- Control groups ---

Cgroup: [enabled]

Cgroup clone_children flag: [enabled]

Cgroup device: [enabled]

Cgroup sched: [enabled]

Cgroup cpu account: [enabled]

Cgroup memory controller: [enabled]

Cgroup cpuset: [enabled]

--- Misc ---

Veth pair device: [enabled]

Macvlan: [enabled]

Vlan: [enabled]

File capabilities: [enabled]

Note : Before booting a new kernel, you can check its configuration

usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig


Tags: thetest命令infocontainernotenablednamespace
1条回答
网友
1楼 · 发布于 2024-04-18 21:19:43

这条评论❝The user id in the lxc instance should equal the user id in the host.❞让我找到了我的解决方案。在

当我以root用户身份运行IPython会话时,一切都按预期运行。哼!在

ps -aux | grep python

root 1327 0.0 0.4 18956 13188 ? S 09:55 0:00 /usr/bin/python /srv/lwp/lwp.py

sudo lxc-info name test-container

Name: test-container

State: STOPPED

相关问题 更多 >