1、降级内核,因为默认内核不反对docker运行,docker个别要求内核版本在3.10以上

(1)查看内核版本

$ uname -r

(2)导入公钥数字证书

$ rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

须要留神的是,根据官网提供,centos6.x对应证书都是这样

(3)装置ELRepo

$ rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

(4)装置 kernel-lt(lt=long-term)

$ yum --enablerepo=elrepo-kernel install kernel-lt -y

(5) 编辑grub.conf文件,批改Grub疏导程序,确认刚装置好的内核在哪个地位,而后设置default值(从0开始),个别新装置的内核在第一个地位,所以设置default=0。

# grub.conf generated by anaconda## Note that you do not have to rerun grub after making changes to this file# NOTICE:  You have a /boot partition.  This means that#          all kernel and initrd paths are relative to /boot/, eg.#          root (hd0,0)#          kernel /vmlinuz-version ro root=/dev/mapper/vg_eypdyf83-lv_root#          initrd /initrd-[generic-]version.img#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (4.4.163-1.el6.elrepo.x86_64)

(6)重启零碎,查看零碎内核能够发现内核曾经更新了

2、装置docker

(1)禁用selinux,因为selinux和LXC有抵触,故而须要禁用

# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#     enforcing - SELinux security policy is enforced.#     permissive - SELinux prints warnings instead of enforcing.#     disabled - No SELinux policy is loaded.SELINUX=disabled  # 此处进行批改即可# SELINUXTYPE= can take one of these two values:#     targeted - Targeted processes are protected,#     mls - Multi Level Security protection.SELINUXTYPE=targeted 

(2)装置 Fedora EPEL

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

(3)装置docker

$ yum install -y docker-io

(4)以守护模式运行Docker

$ docker -d

(5)将Docker开机启动

$ chkconfig docker on

(6)启动Docker

$ service docker start

3、创立docker用户组

默认状况下,docker 命令会应用 Unix socket 与 Docker 引擎通信。而只有 root 用户和 docker 组的用户才能够拜访 Docker 引擎的 Unix socket。出于平安思考,个别 Linux 零碎上不会间接应用 root 用户。因而,更好地做法是将须要应用 docker 的用户退出 docker 用户组。

(1)创立用户组

$ sudo groupadd docker

(2)将当期用户退出用户组

$ sudo usermod -aG docker $USER

(3)也能够创立一个新用户退出到docker用户组

$ sudo usermod -aG docker dockerio