一、升级内核,因为默认内核不支持docker运行,docker通常要求内核版本在3.10以上linux
(1)查看内核版本docker
$ uname -r
(2)导入公钥数字证书centos
$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
须要注意的是,依据官网提供,centos6.x对应证书都是这样安全
(3)安装ELRepoapp
$ rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
(4)安装 kernel-lt(lt=long-term)socket
$ yum --enablerepo=elrepo-kernel install kernel-lt -y
(5) 编辑grub.conf文件,修改Grub引导顺序,确认刚安装好的内核在哪一个位置,而后设置default值(从0开始),通常新安装的内核在第一个位置,因此设置default=0。this
# 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/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (4.4.163-1.el6.elrepo.x86_64)
(6)重启系统,查看系统内核能够发现内核已经更新了code
二、安装dockerthree
(1)禁用selinux,由于selinux和LXC有冲突,故而须要禁用ci
# 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
三、建立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