Lxc start containername without any error, but the container keeps stopped

lxc version: 5.0.1
kernel version is 6.0.7
gentoo

i execute

$ lxc start archcon

without any error, and $? is 0, but the container is not really started. it is still stopped.

when i execute lxc info archcon, it prints:

Name: archcon
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2022/11/17 01:08 HKT
Last Used: 2022/11/17 01:08 HKT

Does it work without being privileged or on a different kernel?

What does lxc info <instance> --show-log show?

lxc info archcon --show-log (this is a archlinux container image that created some days ago)

Name: archcon
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2022/11/17 01:08 HKT
Last Used: 2022/11/21 01:27 HKT

Log:

lxc archcon 20221120172739.744 WARN     cgfsng - ../lxc-5.0.1/src/lxc/cgroups/cgfsng.c:cgroup_tree_remove:489 - No such file or directory - Failed to destroy 23(lxc.payload.archcon)

And I also created a ubuntu container whose name is ubuntucon:

Name: ubuntucon
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2022/11/21 01:24 HKT
Last Used: 2022/11/21 01:27 HKT

Log:

lxc ubuntucon 20221120172743.781 WARN     cgfsng - ../lxc-5.0.1/src/lxc/cgroups/cgfsng.c:fchowmodat:1611 - No such file or directory - Failed to fchownat(44, memory.oom.group, 1000000000, 0, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW )
lxc ubuntucon 20221120172743.781 WARN     cgfsng - ../lxc-5.0.1/src/lxc/cgroups/cgfsng.c:fchowmodat:1611 - No such file or directory - Failed to fchownat(44, memory.reclaim, 1000000000, 0, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW )
lxc ubuntucon 20221120172743.990 WARN     cgfsng - ../lxc-5.0.1/src/lxc/cgroups/cgfsng.c:cgroup_tree_remove:489 - No such file or directory - Failed to destroy 23(lxc.payload.ubuntucon)

Can you run lxc monitor --type=logging --pretty in one terminal and then try starting a container and collecting the output here. Thanks

DEBUG  [2022-11-22T14:15:08+08:00] Event listener server handler started         id=eed65e0b-bf46-4a60-825e-f3e468933136 local=/var/lib/lxd/unix.socket remote=@
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url=/1.0 username=root
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url=/1.0/instances/archcon username=root
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url=/1.0/events username=root
DEBUG  [2022-11-22T14:15:12+08:00] Event listener server handler started         id=093559d2-9ffc-4239-b866-9cbffe4abd47 local=/var/lib/lxd/unix.socket remote=@
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=PUT protocol=unix url=/1.0/instances/archcon/state username=root
DEBUG  [2022-11-22T14:15:12+08:00] Started operation                             class=task description="Starting instance" operation=b5914ff8-7ae1-4e2f-9373-0ca32ae5c804 project=default
DEBUG  [2022-11-22T14:15:12+08:00] New operation                                 class=task description="Starting instance" operation=b5914ff8-7ae1-4e2f-9373-0ca32ae5c804 project=default
DEBUG  [2022-11-22T14:15:12+08:00] Start started                                 instance=archcon instanceType=container project=default stateful=false
DEBUG  [2022-11-22T14:15:12+08:00] Instance operation lock created               action=start instance=archcon project=default reusable=false
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url=/1.0/operations/b5914ff8-7ae1-4e2f-9373-0ca32ae5c804 username=root
DEBUG  [2022-11-22T14:15:12+08:00] MountInstance started                         instance=archcon project=default
DEBUG  [2022-11-22T14:15:12+08:00] MountInstance finished                        instance=archcon project=default
DEBUG  [2022-11-22T14:15:12+08:00] Starting device                               device=eth0 instance=archcon instanceType=container project=default type=nic
DEBUG  [2022-11-22T14:15:12+08:00] Scheduler: network: vetha73060c0 has been added: updating network priorities 
DEBUG  [2022-11-22T14:15:12+08:00] Scheduler: network: vetha64d86c8 has been added: updating network priorities 
DEBUG  [2022-11-22T14:15:12+08:00] Starting device                               device=root instance=archcon instanceType=container project=default type=disk
DEBUG  [2022-11-22T14:15:12+08:00] UpdateInstanceBackupFile started              instance=archcon project=default
INFO   [2022-11-22T14:15:12+08:00] Starting container                            action=start created="2022-11-16 17:08:17.54250929 +0000 UTC" ephemeral=false instance=archcon instanceType=container project=default stateful=false used="2022-11-22 06:14:46.60381226 +0000 UTC"
DEBUG  [2022-11-22T14:15:12+08:00] Skipping unmount as in use                    driver=dir pool=lxdstorage refCount=1 volName=archcon
DEBUG  [2022-11-22T14:15:12+08:00] UpdateInstanceBackupFile finished             instance=archcon project=default
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url="/internal/containers/archcon/onstart?project=default" username=root
DEBUG  [2022-11-22T14:15:12+08:00] Scheduler: container archcon started: re-balancing 
DEBUG  [2022-11-22T14:15:12+08:00] Instance operation lock finished              action=start err="<nil>" instance=archcon project=default reusable=false
INFO   [2022-11-22T14:15:12+08:00] Started container                             action=start created="2022-11-16 17:08:17.54250929 +0000 UTC" ephemeral=false instance=archcon instanceType=container project=default stateful=false used="2022-11-22 06:14:46.60381226 +0000 UTC"
DEBUG  [2022-11-22T14:15:12+08:00] Start finished                                instance=archcon instanceType=container project=default stateful=false
DEBUG  [2022-11-22T14:15:12+08:00] Success for operation                         class=task description="Starting instance" operation=b5914ff8-7ae1-4e2f-9373-0ca32ae5c804 project=default
DEBUG  [2022-11-22T14:15:12+08:00] Event listener server handler stopped         listener=093559d2-9ffc-4239-b866-9cbffe4abd47 local=/var/lib/lxd/unix.socket remote=@
DEBUG  [2022-11-22T14:15:12+08:00] Scheduler: network: eth0 has been added: updating network priorities 
DEBUG  [2022-11-22T14:15:12+08:00] Handling API request                          ip=@ method=GET protocol=unix url="/internal/containers/archcon/onstopns?netns=%2Fproc%2F8506%2Ffd%2F51&project=default&target=stop" username=root
DEBUG  [2022-11-22T14:15:12+08:00] Instance initiated stop                       action=stop instance=archcon instanceType=container project=default
DEBUG  [2022-11-22T14:15:12+08:00] Instance operation lock created               action=stop instance=archcon project=default reusable=false
DEBUG  [2022-11-22T14:15:12+08:00] Stopping device                               device=eth0 instance=archcon instanceType=container project=default type=nic
DEBUG  [2022-11-22T14:15:13+08:00] Handling API request                          ip=@ method=GET protocol=unix url="/internal/containers/archcon/onstop?project=default&target=stop" username=root
DEBUG  [2022-11-22T14:15:13+08:00] Container stopped, cleaning up                instance=archcon instanceType=container project=default
DEBUG  [2022-11-22T14:15:13+08:00] Stopping device                               device=root instance=archcon instanceType=container project=default type=disk
DEBUG  [2022-11-22T14:15:13+08:00] UnmountInstance started                       instance=archcon project=default
DEBUG  [2022-11-22T14:15:13+08:00] UnmountInstance finished                      instance=archcon project=default
DEBUG  [2022-11-22T14:15:13+08:00] Scheduler: container archcon stopped: re-balancing 
DEBUG  [2022-11-22T14:15:13+08:00] Instance operation lock finished              action=stop err="<nil>" instance=archcon project=default reusable=false

Is your Gentoo on openrc, and the container is systemd (as it is arch it most likely is?)

If yes, make sure your kernel has openrc and systemd support,

# zgrep -i gentoo_linux_init /proc/config.gz 
CONFIG_GENTOO_LINUX_INIT_SCRIPT=y
CONFIG_GENTOO_LINUX_INIT_SYSTEMD=y

and do this in your host:

root #install -d /sys/fs/cgroup/systemd
root #chown root:lxd /sys/fs/cgroup/systemd
root #mount -t cgroup -o none,name=systemd systemd /sys/fs/cgroup/systemd

And try again.

https://wiki.gentoo.org/wiki/LXD#Alternative_way_.28lxd-4.0.9.29

2 Likes

Thank you very much. Following your guide, it works well, although CONFIG_GENTOO_LINUX_INIT_SCRIPT and CONFIG_GENTOO_LINUX_INIT_SYSTEMD can’t be even found in /proc/config.gz