I have my LXC container configured and running fine. The very last step in my setup was to add it into lxc-auto to make sure it is running after reboot.
Unfortunately this works for my only partially. If I reboot my router the container is up and running however it is not assigned IP address via DHCP and I can see error in log - network initialization failed.
I don’t think there is any problem with a setup of my router as if I connect to the container and run /etc/init.d/network restart everything works fine. I believe the problem is in starting the container before networking on my router is fully up and running.
Please can somebody help me to setup a LXC container to auto-start after reboot in a way to be able to use DHCP? Sure, I can assign static IP address, but I’d prefer to stay with the DHCP option
I have tried hack described below and it works, but I don’t like it very much.
So, if anybody knows how to fix this in a clean way, please let me know.
I am starting LXC containers with 60 secs (configurable) delay. To prevent too long boot time containers are started in background. Assuming to start multiple container in parallel is not a problem.
Here are my changes
I made copy of lxc-auto under name lxc-dauto (read LXC delayed auto start). Here is the output of diff lxc-auto lxc-dauto