How to Auto Start LXCs when Host Starts

LXCs don’t normally auto start when the host server starts. We have to manually configure them to auto start.

Go to the LXC directory from your host server. All LXCs are stored in the /var/lib/lxc/ directory of the host, and all LXCs have a directory with their name inside that directory. So, if the name of your LXC is com-budhajeewa, that LXC’s directory would be /var/lib/lxc/com-budhajeewa. cd into it.

Now open the config file which is in that directory, and add the following lines at the end of it:

#Auto Start
lxc.start.auto = 1
lxc.start.delay = 5

You can verify that your configuration change worked by issuing lxc-ls -f command. You’ll get an output like this:

NAME           STATE   AUTOSTART GROUPS IPV4     IPV6 
com-budhajeewa RUNNING 1         -      10.0.3.2 -

If “Autostart” is set to “1”, all has gone well.

Leave a Reply