lxc/lxc — pull request #107 by SethRobertson (2013-12-04 17:51:27+00:00)
Title: Improve usefulness of lxc-unshare for lightweight test containers

When I was doing some exploration of LXC and some of the capabilities it has, I started using lxc-unshare continuously. However, I noticed that some actions were needed almost every time I used it. Some were easy to do, but annoying to repeat, others were not even easy to do. So, this pull request contains some fixes I made to greatly improve the usability of the system. Using this on my laptop, I was able to create 4900 networked containers, which is great when trying to do basic Internet simulation (routers don't need to do much). Creating an OS container is much more than I wanted.

First, I removed the restrictions on -u. Since you normally need to be root when running lxc_unshare, it is completely reasonable to setuid to some other user, even (or perhaps even especially) if the UID namespace is not private.

Second, I added the -i argument to automatically pass interfaces into the container. They don't do renaming, mac reassignment, IP assignment, bridge assignment, or the other fancy features of a full started container, but for light weight testing, this gives you much greater flexibility.

Third, I added the -H argument to set the hostname. Nothing exciting, but no reason not to.

Next, I added the -M argument to automatically call lxc_setup_fs to mount /proc /dev/shm and /dev/mqueue. Since people often want private namespaces, this option saves people from having to do those manually over and over (or worse, forgetting to do so).

Finally, I added the -D argument to daemonize (or at least the light weight version thereof) the container so that you don't have extra processes hanging around whose sole purpose is to wait and print error messages.

I believe accepting these options will make the program much more useful and usable.

Thanks,
Seth Robertson