Comment 5 for bug 1348663

St├ęphane Graber (stgraber) wrote :

I just checked and ifdown does call -r and so should release the address, specifically, we call:
    dhclient -v -r -pf /run/dhclient.%iface%.pid -lf /var/lib/dhcp/dhclient.%iface%.leases %iface%

Now, that'd obviously only be called if the container was cleanly shutdown and not simply killed.
So assuming a container called "test":
 - sudo lxc-stop -n test => will call ifdown in the shutdown sequence and timeout after 30s forcefully killing the container then
 - sudo lxc-stop -n test -k => will NOT call ifdown as all the container tasks will just get SIGKILLed

This is for LXC 1.x, before it, we had a bunch of different commands doing those steps. So if you are shelling out to LXC and need to support 12.04 and 14.04, you'd want something like this:

Clean shutdown:
 - If lxc-shutdown exists, call: lxc-shutdown -n <container> -t 30
 - Otherwise, call: lxc-stop -n <container>

Forcefully killing stuff (ifdown won't get called):
 - If lxc-shutdown exists, call: lxc-stop -n <container>
 - Otherwise, call: lxc-stop -n <container> -k