Skip to content

Instantly share code, notes, and snippets.

@l1x
Last active November 5, 2016 18:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save l1x/32a9dbd0f6ff5c79d84bb9fb7d55b4c7 to your computer and use it in GitHub Desktop.

Installing LXC on CentOS 7.2

Version

[root@be0 ~]# cat -v /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

Installing

yum install epel-release
yum install lxc lxc-templates libvirt wget

Packages

Dependencies Resolved

=================================================================================================================================================
 Package                                Arch                           Version                                Repository                    Size
=================================================================================================================================================
Installing:
 lxc                                    x86_64                         1.0.8-1.el7                            epel                         140 k
 lxc-templates                          x86_64                         1.0.8-1.el7                            epel                          81 k
Installing for dependencies:
 libseccomp                             x86_64                         2.2.1-1.el7                            base                          49 k
 lua-alt-getopt                         noarch                         0.7.0-4.el7                            epel                         7.4 k
 lua-filesystem                         x86_64                         1.6.2-2.el7                            epel                          28 k
 lua-lxc                                x86_64                         1.0.8-1.el7                            epel                          17 k
 lxc-libs                               x86_64                         1.0.8-1.el7                            epel                         271 k

Transaction Summary
=================================================================================================================================================
Install  2 Packages (+5 Dependent packages)

Starting up LXC

[root@be0 ~]# systemctl start lxc.service

Checking status:

[root@be0 ~]#  systemctl status lxc.service
● lxc.service - LXC Container Initialization and Autoboot Code
   Loaded: loaded (/usr/lib/systemd/system/lxc.service; disabled; vendor preset: disabled)
   Active: active (exited) since Sat 2016-11-05 18:00:33 UTC; 59s ago
  Process: 10250 ExecStop=/usr/libexec/lxc/lxc-autostart-helper stop (code=exited, status=0/SUCCESS)
  Process: 10257 ExecStart=/usr/libexec/lxc/lxc-autostart-helper start (code=exited, status=0/SUCCESS)
  Process: 10254 ExecStartPre=/usr/libexec/lxc/lxc-devsetup (code=exited, status=0/SUCCESS)
 Main PID: 10257 (code=exited, status=0/SUCCESS)

Nov 05 18:00:03 be0.be.local systemd[1]: Starting LXC Container Initialization and Autoboot Code...
Nov 05 18:00:03 be0.be.local lxc-devsetup[10254]: /dev is devtmpfs
Nov 05 18:00:33 be0.be.local lxc-autostart-helper[10257]: Starting LXC autoboot containers:  [  OK  ]
Nov 05 18:00:33 be0.be.local systemd[1]: Started LXC Container Initialization and Autoboot Code.

Checking configuration:

[root@be0 ~]# lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.10.0-327.36.3.el7.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 clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled

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

--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: enabled

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

Creating an instance based on CentOS template

[root@be0 ~]# lxc-create -n bebe-centos-test -t /usr/share/lxc/templates/lxc-centos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment