Debug options for LXC and lxc-start when lxc container could not start

Author:

Setup and running LXC container is really easy, but sometimes it is unclear why the LXC container could not start. Most of the time, there is a generic error, which says nothing for the real reason:

root@srv ~ # lxc-start -n test-lxc
lxc-start: test-lxc: lxccontainer.c: wait_on_daemonized_start: 867 Received container state "ABORTING" instead of "RUNNING"
lxc-start: test-lxc: tools/lxc_start.c: main: 306 The container failed to start
lxc-start: test-lxc: tools/lxc_start.c: main: 309 To get more details, run the container in foreground mode
lxc-start: test-lxc: tools/lxc_start.c: main: 311 Additional information can be obtained by setting the --logfile and --logpriority options

No specific reason why the LXC container test-lxc can not be started and the lxc-start command failed. There is just an offer to use the logging options and here is how the administrator of the box may do it by including the following lxc-start options:

-l DEBUG –logfile=test-lxc.log –logpriority=9

Here is a real-world example of an old kernel trying to run LXC 4.0

root@srv ~ # lxc-start -n test-lxc -F -l DEBUG --logfile=test-lxc.log --logpriority=9
lxc-start: test-lxc: utils.c: lxc_can_use_pidfd: 1774 Kernel does not support pidfds
lxc-start: test-lxc: network.c: netdev_configure_server_macvlan: 866 No link for macvlan network device specified
lxc-start: test-lxc: network.c: lxc_create_network_priv: 3413 Invalid argument - Failed to create network device
lxc-start: test-lxc: start.c: lxc_spawn: 1837 Failed to create the network
lxc-start: test-lxc: start.c: __lxc_start: 2068 Failed to spawn container "test-lxc"
lxc-start: test-lxc: tools/lxc_start.c: main: 306 The container failed to start
lxc-start: test-lxc: tools/lxc_start.c: main: 311 Additional information can be obtained by setting the --logfile and --logpriority options

The reason here is the old kernel, which does not support pidfds and a kernel upgrade is needed here! Missing kernel feature leads to the start of the LXC container network and the start of the container fails.

Activating the debug options in the proper way could save you hours even in simple cases when an incidental minor mistake presents in the root path or other file in the configuration:

root@srv ~ # lxc-start -n test-lxc
lxc-start: test-lxc: lxccontainer.c: wait_on_daemonized_start: 867 Received container state "ABORTING" instead of "RUNNING"
lxc-start: test-lxc: tools/lxc_start.c: main: 306 The container failed to start
lxc-start: test-lxc: tools/lxc_start.c: main: 309 To get more details, run the container in foreground mode
lxc-start: test-lxc: tools/lxc_start.c: main: 311 Additional information can be obtained by setting the --logfile and --logpriority options
root@srv ~ # lxc-start -n test-lxc -F -l DEBUG --logfile=test-lxc.log --logpriority=9
lxc-start: test-lxc: conf.c: lxc_rootfs_init: 568 No such file or directory - Failed to open "/var/lib/lxc/tst-lxc/rootfs"
lxc-start: test-lxc: start.c: __lxc_start: 2040 Failed to handle rootfs pinning for container "test-lxc"
lxc-start: test-lxc: tools/lxc_start.c: main: 306 The container failed to start
lxc-start: test-lxc: tools/lxc_start.c: main: 311 Additional information can be obtained by setting the --logfile and --logpriority options

Starting without logging options just outputs the generic error of being unable to start the LXC with no actual reason. And including the debug options reveals the exact error – just cannot open the root path of the LXC container. Simple, but common error when copying from an old LXC container configuration. The real root path is /var/lib/lxc/test-lxc/rootfs, not the used one /var/lib/lxc/tst-lxc/rootfs.

Leave a Reply

Your email address will not be published. Required fields are marked *