Slackware: CentOS linux container

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
    /usr/sbin/iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE
    /sbin/sysctl net.ipv4.ip_forward=1

Create the Container

  • execute lxc-create –name Name –template=centos –dir=Path
    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 = veth = up = br0 = eth0

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 as ip address and your bridge will use

Leave a comment