Ubuntu LXC-Container not booting after setting a static IP

Today I had a weird problem with one of my lxc-containers on a Ubuntu 14.04 Host.. for no reason, the container changed its IP address.. This lead to the other containers not finding the container in question under its IP anymore.

I then tried to manually set the IP of the container in /etc/network/interfaces like this

# auto eth0
# iface eth0 inet static
# address 192.168.0.42
# network 192.168.0.0
# netmask 255.255.255.0
# broadcast 192.168.0.255
# gateway 192.168.0.1

However, this was not a good idea.. the container failed to start and basically hung like this:

# lxc-start -n lyrix-prod
<4>init: plymouth-upstart-bridge main process (5) terminated with status 1
<4>init: plymouth-upstart-bridge main process ended, respawning
<4>init: hwclock main process (7) terminated with status 77
<4>init: plymouth-upstart-bridge main process (15) terminated with status 1
<4>init: plymouth-upstart-bridge main process ended, respawning
<4>init: ureadahead main process (8) terminated with status 5
<4>init: plymouth-upstart-bridge main process (19) terminated with status 1
<4>init: plymouth-upstart-bridge main process ended, respawning
* Starting Mount filesystems on boot ...done.
* Stopping Send an event to indicate plymouth is up ...done.
* Starting Signal sysvinit that the rootfs is mounted ...done.
* Stopping Read required files in advance (for other mountpoints) ...done.
* Starting Clean /tmp directory ...done.
* Stopping Clean /tmp directory ...done.
* Starting Populate and link to /run filesystem ...done.
* Stopping Populate and link to /run filesystem ...done.
* Starting Track if upstart is running in a container ...done.
* Starting load fallback graphics devices ...done.
* Starting workaround for missing events in container ...done.
<4>init: udev-fallback-graphics main process (101) terminated with status 1
* Starting load fallback graphics devices ...fail!
<4>init: console-font main process (119) terminated with status 1
* Stopping workaround for missing events in container ...done.
* Starting userspace bootsplash ...done.
* Starting Initialize or finalize resolvconf ...done.
<4>init: setvtrgb main process (133) terminated with status 1
* Starting Send an event to indicate plymouth is up ...done.
* Starting configure network device security ...done.
* Stopping userspace bootsplash ...done.
<4>init: console-setup main process (153) terminated with status 1
* Stopping Send an event to indicate plymouth is up ...done.
* Starting Signal sysvinit that virtual filesystems are mounted ...done.
* Starting Signal sysvinit that virtual filesystems are mounted ...done.
* Starting Bridge udev events into upstart ...done.
* Starting Mount network filesystems ...done.
* Starting Signal sysvinit that local filesystems are mounted ...done.
* Starting configure network device security ...done.
* Starting device node and kernel event manager ...done.
<30>systemd-udevd[202]: starting version 204
* Starting Signal sysvinit that remote filesystems are mounted ...done.
* Starting Failsafe Boot Delay ...done.
* Starting flush early job output to logs ...done.
* Starting load modules from /etc/modules ...done.
* Stopping Mount filesystems on boot ...done.
* Stopping load modules from /etc/modules ...done.
* Stopping flush early job output to logs ...done.
* Stopping Mount network filesystems ...done.
* Starting configure network device ...done.
* Starting configure virtual network devices ...done.
* Starting system logging daemon ...done.
* Starting Bridge socket events into upstart ...done.
* Starting Bridge file events into upstart ...done.
^C ---- container was stuck here....

I resolved it with this ServerFault answer .. now I always configure my containers IP in its container-config file and let the container use the IP it gets from “the BIOS”.

/var/lib/lxc/$containername/config
lxc.network.type=veth
lxc.network.link=lxcbr0
lxc.network.flags=up
lxc.network.ipv4 = 10.0.3.220/24
lxc.network.ipv4.gateway = auto

The containers /etc/network/interfaces now looks like this


auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

Tada! My containers now always get the IPs I want them to get 🙂

Leave a comment

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