Step by step guild to create a Centos 6.5 LXC container in ubuntu.
If you’re here it means that you have difficulties installing Centos LXC container in Ubuntu! Like I did. But no worries by following this step by step guide you should have no problems.
- Ubuntu 13.10 – 64bit (I’m using latest version installed on my box)
- Internet connection
you’ll need the following packages in Ubuntu in order to install Centos container:
$ sudo apt-get install lxc yum git
The default LXC installation on Ubuntu does not come with CentOS template, you need to get it from GIST, I did some modification to original one in order to work on Ubuntu 13.10.
Using GIT to fetch template:
$ git clone https://gist.github.com/7944511.git lxc-centos
Or just open Gist Url with your browser and click
Download Gist button. Don’t forget to change the source path in copy to the one you saved template file in next step. [thanks to Duffy Gillman for this suggestion]
And then you should copy this template in LXC default template directory.
$ sudo cp lxc-centos/lxc-centos /usr/share/lxc/templates/ $ sudo chmod +x /usr/share/lxc/templates/lxc-centos
Now it’s time to create LXC container:
$ sudo lxc-create -n centos-01 -t centos
You need patience here! It’s going to download all required packages from the Internet and extract them in container’s rootfs directory. Now go and make a coffee and watch the process …
You can issue the following command to start new container:
$ sudo lxc-start -n centos-01
above command will get you directly into interactive console of the container, it’s good for testing purpose but while you are there you can not get out of it until you shutdown the container. Instead you can start container in background with this command:
$ sudo lxc-start -n centos-01 -d
Wait for few seconds to boot the container and you can use lxc-console command or ssh to connect to it:
$ sudo lxc-console -n centos-01
$ host centos-01 10.0.3.1
this will give you container’s IP address and then:
$ ssh root@<ip address from above command output>
NOTE: default username and password for CentOS container is