Install docker.io on CentOS 6.x

  • 2020-05-17 07:21:01
  • OfStack

The docker container was first fully supported by RHEL since the recent CentOS 7.0, which officially runs only on 64-bit architecture platforms with kernel versions 2.6.32-431 and above (i.e > =CentOS 6.5, when running docker, the actual prompt is 3.8.0 and above), please refer to CentOS 6.x kernel upgrade (2.6.32 -) > 3.10.58) process records

It is important to note that the installation of CentOS 6.5 is slightly different from that of 7.0. The installation package of docker on CentOS-6 is called docker-io and comes from the Fedora epel library. This warehouse maintains a large number of software not included in the distribution, so you should install EPEL first. The docker of CentOS-7 is directly contained in the Extras repository of the official mirror source (enable=1 enabled under section [extras] of CentOS-Base.repo). The premise is the need to network, the specific installation process is as follows.

1. Disable selinux


# getenforce
enforcing
# setenforce 0
permissive
# vi /etc/selinux/config
SELINUX=disabled
...

2. Install Fedora EPEL

The epel-release-6-8.noarch.rpm package comes with the distribution media and can be installed from rpm.


# yum install epel-release-6-8.noarch.rpm
// or 
yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

If a GPG key retrieval failed: [14] Errno Could not open/read file: / / / etc pki/rpm - gpg/RPM - GPG - KEY - EPEL - 6 questions, please install epel online, download RPM - GPG - KEY - EPEL - 6 files.

After this step 1, can be in/etc/yum repos. d/next generation epel repo, epel - testing. repo two files, used for download rpm package from Fedora website.

3. Check the kernel version


# uname -r
2.6.32-431.el6.x86_64
# cat /etc/redhat-release 
CentOS release 6.5 (Final)

Looking at the lowest version of the kernel, it actually works fine and you can upgrade to the 3.10.x version.

You can also run the script check-config.sh to check that the kernel module characters do not match (here are some of missing's, but my docker still starts properly) :


[root@sean ~]# ./check-config 
warning: /proc/config.gz does not exist, searching other paths for kernel config...
info: reading kernel config from /boot/config-2.6.32-431.el6.x86_64 ...

Generally Necessary:
- cgroup hierarchy: properly mounted [/cgroup]
- CONFIG_NAMESPACES: enabled
- CONFIG_NET_NS: enabled
- CONFIG_PID_NS: enabled
- CONFIG_IPC_NS: enabled
- CONFIG_UTS_NS: enabled
- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled
- CONFIG_CGROUPS: enabled
- CONFIG_CGROUP_CPUACCT: enabled
- CONFIG_CGROUP_DEVICE: enabled
- CONFIG_CGROUP_FREEZER: enabled
- CONFIG_CGROUP_SCHED: enabled
- CONFIG_MACVLAN: enabled
- CONFIG_VETH: enabled
- CONFIG_BRIDGE: enabled
- CONFIG_NF_NAT_IPV4: missing
- CONFIG_IP_NF_TARGET_MASQUERADE: enabled
- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: missing
- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled
- CONFIG_NF_NAT: enabled
- CONFIG_NF_NAT_NEEDED: enabled

Optional Features:
- CONFIG_MEMCG_SWAP: missing
- CONFIG_RESOURCE_COUNTERS: enabled
- CONFIG_CGROUP_PERF: enabled
- Storage Drivers:
 - "aufs":
 - CONFIG_AUFS_FS: missing
 - CONFIG_EXT4_FS_POSIX_ACL: enabled
 - CONFIG_EXT4_FS_SECURITY: enabled
 - "btrfs":
 - CONFIG_BTRFS_FS: enabled
 - "devicemapper":
 - CONFIG_BLK_DEV_DM: enabled
 - CONFIG_DM_THIN_PROVISIONING: enabled
 - CONFIG_EXT4_FS: enabled
 - CONFIG_EXT4_FS_POSIX_ACL: enabled
 - CONFIG_EXT4_FS_SECURITY: enabled

If you are compiling your own kernel, be aware of a few must-have features: DM_THIN_PROVISIONING, IP_NF_TARGET_MASQUERADE, NF_NAT. (there is no corresponding option for AUFS_FS, it is not clear what is going on, but it is not required)

4. Install docker - io


# yum install docker-io
Dependencies Resolved

===========================================================================================
 Package      Arch    Version   Repository  Size
===========================================================================================
Installing:
 docker-io      x86_64   1.1.2-1.el6   epel   4.5 M
Installing for dependencies:
 lua-alt-getopt     noarch   0.7.0-1.el6   epel   6.9 k
 lua-filesystem     x86_64   1.4.2-1.el6   epel   24 k
 lua-lxc      x86_64   1.0.6-1.el6   epel   15 k
 lxc       x86_64   1.0.6-1.el6   epel   120 k
 lxc-libs      x86_64   1.0.6-1.el6   epel   248 k

Transaction Summary
===========================================================================================
Install  6 Package(s)

With many documents covered here, the next step is to mount the /cgroup file system. My version of docker is 1.1.2, without modifying the /etc/fstab step.

5. Start the trial run


# service docker start
// or 
# docker -d 

Abnormal 6.

During my first installation, I unfortunately encountered the following problems:

docker-d startup, or tail-f /var/log/docker view log


[f32e7d9f] +job initserver()
[f32e7d9f.initserver()] Creating server
[f32e7d9f] +job serveapi(unix:///var/run/docker.sock)
2014/10/22 13:02:45 Listening for HTTP on unix (/var/run/docker.sock)
Error running DeviceCreate (createPool) dm_task_run failed
[f32e7d9f] -job initserver() = ERR (1)
2014/10/22 13:02:45 Error running DeviceCreate (createPool) dm_task_run failed
\nWed Oct 22 14:35:54 CST 2014\n

Or service docker restart


Stopping docker:            [ OK ]
Starting cgconfig service: Error: cannot mount cpuset to /cgroup/cpuset: Device or resource busy
/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Failed to parse /etc/cgconfig.conf       [FAILED]

Starting docker:            [ OK ]

Unable to enable network bridge NAT: iptables failed: iptables -I POSTROUTING -t nat -s 172.17.42.1/16 ! -d 172.17.42.1/16 -j MASQUERADE: iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

The above three exceptions are all due to the lack of kernel modules, which is also the risk of compiling the kernel to upgrade, so you have sciurus's kernel-ml-aufs's rpm package (see the first link for reference).


Related articles: