我对 LXC 和 LXD 概念非常陌生。我通过创建容器并销毁它们来试验 LXC。
经过一些实验,我尝试创建一个容器来实现任务,成功创建了容器但无法启动它。出现以下错误。
我尝试过卸载并安装 lxc 和 lxd。我尝试过清除 lxc 和 lxd,但没有成功。我查阅了一些表格,但无法解决我的问题。
请告诉我这里出了什么问题。
我知道我无法完全移除被毁坏的容器,但不确定如何移除它们。
运行时sudo lxc-start -n vims
出现以下错误:
lxc-start: lxccontainer.c: wait_on_daemonized_start: 804 Received container state "STOPPING" instead of "RUNNING"
The container failed to start.
To get more details, run the container in foreground mode.
Additional information can be obtained by setting the --logfile and --logpriority options.
使用日志文件运行时sudo lxc-start -n vims --logfile errorlog.txt
日志文件的输出如下:
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:create_path_for_hierarchy:1720 - The cgroup "/sys/fs/cgroup/systemd//lxc/vims" already existed
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:cgfsng_create:1804 - Failed to create cgroup "/sys/fs/cgroup/systemd//lxc/vims"
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:create_path_for_hierarchy:1720 - The cgroup "/sys/fs/cgroup/systemd//lxc/vims-1" already existed
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:cgfsng_create:1804 - Failed to create cgroup "/sys/fs/cgroup/systemd//lxc/vims-1"
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:create_path_for_hierarchy:1720 - The cgroup "/sys/fs/cgroup/systemd//lxc/vims-2" already existed
lxc-start 20210607162943.382 ERROR lxc_cgfsng - cgroups/cgfsng.c:cgfsng_create:1804 - Failed to create cgroup "/sys/fs/cgroup/systemd//lxc/vims-2"
lxc-start 20210607162943.476 ERROR lxc_start - start.c:start:1891 - Exec format error - Failed to exec "/sbin/init"
lxc-start 20210607162943.476 ERROR lxc_sync - sync.c:__sync_wait:59 - An error occurred in another process (expected sequence number 7)
lxc-start 20210607162943.476 ERROR lxc_start - start.c:__lxc_start:1802 - Failed to spawn container "vims".
lxc-start 20210607162943.476 ERROR lxc_container - lxccontainer.c:wait_on_daemonized_start:804 - Received container state "STOPPING" instead of "RUNNING"
正如错误日志中提到的,如果我们检查/sys/fs/cgroup/systemd/lxc
目录,内容如下
drwxr-xr-x 2 root root 0 Jun 7 16:32 container_2
drwxr-xr-x 2 root root 0 Jun 7 16:33 container_2-1
drwxr-xr-x 2 root root 0 Jun 7 16:33 container_2-2
-rw-r--r-- 1 root root 0 Jun 7 16:34 tasks
-rw-r--r-- 1 root root 0 Jun 7 16:34 notify_on_release
-rw-r--r-- 1 root root 0 Jun 7 16:34 cgroup.procs
-rw-r--r-- 1 root root 0 Jun 7 16:34 cgroup.clone_children
drwxr-xr-x 2 root root 0 Jun 7 17:03 container_2-3
drwxr-xr-x 2 root root 0 Jun 7 17:03 container_2-4
drwxr-xr-x 2 root root 0 Jun 7 17:07 vims
drwxr-xr-x 2 root root 0 Jun 7 17:08 vims-1
drwxr-xr-x 2 root root 0 Jun 7 21:57 vims-2
drwxr-xr-x 2 root root 0 Jun 7 21:59 vims-3
drwxr-xr-x 2 root root 0 Jun 7 22:04 POC
我试图删除上述容器目录,但是 Linux 不允许我这样做。
问题的背景,我创建了多个容器并通过sudo lxc-destroy -n <container_name>
提前致谢!!!