The LXC container software comes to CentOS 8 with the EPEL 8 repository. LXC is a multiprocesses container, which offers to boot a Linux distribution under container isolation. It is very similar to systemd-nspawn and a bit different from docker containers. LXC containers are used when multiple processes are needed under one container only. In most cases, the LXC container is a fully-featured Linux distribution (systemd or SysV, i.e. init) booted under a Linux container.
There are several major differences between docker/podman containers and LXC:
- Multiprocesses.
- Easy configuration modification. Even hot-plugin supported.
- Unprivileged Linux containers.
- Complex network setups. Multiple network interfaces connected to different networks, for example.
- Live systemd, i.e. systemd or SysV init are booted as usual. Much of the software rellies on systemd/udev features and in many cases, it is really hard to run a software without a systemd or init process
Here are the steps to boot a CentOS 8 container under CentOS 8 host server:
STEP 1) Install EPEL repository.
EPEL CentOS 8 repository now includes LXC 3.0 software.
dnf install -y epel-release
STEP 2) Install LXC software and start LXC service.
At present, the LXC software version is 3.0.4. The package lxc-templates includes template scripts to create a Linux distribution environment like CentOS, Ubuntu, Debian, Gentoo, ArchLinux, Oracle, Alpine, and many others and it also includes the configuration templates to start these Linux distributions.
dnf install -y lxc lxc-templates dnf install -y wget tar
The wget and tar are required if LXC templates installation is going to be performed.
STEP 3) Create a CentOS 8 container with the help of LXC templates and run it.
Use the lxc-templates to prepare a CentOS 8 container environment. The currently available containers are listed here http://images.linuxcontainers.org/. Check out the URL and choose the right container. Here the CentOS 8 amd64 is used.
lxc-create --template download -n mycontainer -- --dist centos --release 8 --arch amd64 --keyserver hkp://keyserver.ubuntu.com