Ubuntu 12.04 - Getting Started With LXC

This tutorial is just going to get you hitting the ground running with LXC to prick your interest. As such there is no heavy manipulation of config files or advanced features.

To install LXC and get inside a container simply run the following commands:

sudo apt-get install lxc -y
sudo lxc-create --template ubuntu --name [CONTAINER NAME]

# Wait a significant period of time...

# Start the container and enter into it
sudo lxc-start -d --name [CONTAINER NAME]
sudo lxc-attach --name [CONTAINER NAME]

# have some fun in the container
# exit back out to the host with the "exit" command

# Stop the container when you are finished
sudo lxc-stop --name [CONTAINER NAME]

You can use lxc-start without the -d switch to start the container and automatically enter it. The username will be ubuntu and the password will also be ubuntu, but I had difficulties exiting properly and recommend always using the -d option shown above.

The templates are located at /usr/lib/lxc/templates. There are templates for busybox, debian, fedora, opensuse, sshd, ubuntu, and ubuntu-cloud. You can create your own but that is beyond the scope of this tutorial.

References

No comments:

Post a Comment