If you need to create a CentOS based linux container on your Slackware here you can find how i’ve made it.
Before you start
- (re)compile your kernel including every config option needed to have lxc-checkconfig output “enable” in each line.
- (re)compile your kernel to add support for “networking bridge”
- update rpm package using the one found here
- install yum package, you can find it here
- make sure to have lxc package installed (it’s in the main Slackware repository)
- make sure tu have installed bridge-utils package (it’s in the main Slackware repository)
- make sure to have enough free disk space (my setup used at least 400MB)
- add at the end of /etc/rc.d/rc.local the following lines
/usr/sbin/brctl addbr br0
/usr/sbin/brctl br0 10.0.0.1/24
/usr/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.100 -o eth0 -j MASQUERADE
/sbin/sysctl net.ipv4.ip_forward=1
Create the Container
- execute lxc-create –name Name –template=centos –dir=Path
Name is the name you want to give to your container
Path is the directory you want to use to store all the files - wait and give answers to questions
- enter into Path
- read from tmp_root_pass the password you will use to access, as root, the container shell
- modify file config adding the following lines to the network section
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.ipv4=10.0.0.100
lxc.network.ipv4.gateway=10.0.0.1
lxc.network.flags=up
lxc.network.mtu=1500
Base commands to manage containers
- to start a container use lxc-start –name=Name
- to stop a container use lxc-stop –name=Name
- to see the list of available containers use lxc-ls
Final notes
- this configuration allow you to access your CentOS container only from your Slackare host machine, if you need to access it from outside you have to change your bridge configuration
- to see more commands you can use to manage containers open, as root, a shell, digit lxc and than press twice <tab>
- using my guide your linux container will have 10.0.0.100 as ip address and your bridge will use 10.0.0.1