LXC Installation ( Linux Container )
Linux_containers

This post, we would see how we could install Linux containers in CentOS6. For this setup, we are using CentOS6.9

[root@srv3 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)

Packages Installation

LXC packages are already included in CentOS repositories.

#yum install lxc* libvirt

Always recommend installing packages of lxc. Although lxc and lxc-template are important for functions. Libvirt is also another essential package for LXC function.

Now start lxc and libvirt service on your host.

[root@srv3 ~]# /etc/init.d/lxc restart
Stopping LXC containers:                                   [  OK  ]
Starting LXC autoboot containers:                          [  OK  ]

[root@srv3 ~]# lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-2.6.32-696.6.3.el6.x86_64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
Network namespace: enabled
Multiple /dev/pts instances: enabled

--- Control groups ---
Cgroup: enabled
Cgroup namespace: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: /usr/bin/lxc-checkconfig: line 114: [: -ge: unary operator expected
/usr/bin/lxc-checkconfig: line 114: [: -gt: unary operator expected
enabled
Cgroup cpuset: enabled

--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
Bridges: enabled
Advanced netfilter: enabled
CONFIG_NF_NAT_IPV4: missing
CONFIG_NF_NAT_IPV6: missing
CONFIG_IP_NF_TARGET_MASQUERADE: enabled
CONFIG_IP6_NF_TARGET_MASQUERADE: missing
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled

--- Checkpoint/Restore ---
checkpoint restore: missing
CONFIG_FHANDLE: missing
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: missing
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: missing
CONFIG_NETLINK_DIAG: missing
File capabilities: /usr/bin/lxc-checkconfig: line 148: [: -gt: unary operator expected

Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig

You can’t start any Linux container without libvirt service. it good to start libvirt before creating and Linux Container.

# /etc/init.d/libvirtd start

# chkconfig libvirtd on