Linux 安装docker

前置条件:

64-bit 系统

kernel 3.10+

所以如果内核不到3.10的需要先升级内核

 

CentOS-6.X内核升级

yum安装编译内核
升级前环境:

[[email protected] ~]# uname -a

Linux localhost.localdomain 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

 

1、导入public key这步必须要执行的

[[email protected] ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
 

2、若只想升级至当前的最新稳定内核,只需要执行下面命令

[[email protected] ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

Linux 安装docker

[[email protected] ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y

 

3、编辑grub.conf文件,修改Grub引导顺序(只需要修改default=0)

[[email protected] ~]# vim /etc/grub.conf

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

Linux 安装docker #一般新安装的内核在第一个位置,所以设置default=0,表示启动新内核

 

4、修改后重启系统

[[email protected] ~]# reboot

重启之后再看系统内核就变成最新的4.4了。

[[email protected] ~]# uname -a

Linux localhost.localdomain 4.4.111-1.el6.elrepo.x86_64 #1 SMP Wed Jan 10 14:56:14 EST 2018 x86_64 x86_64 x86_64 GNU/Linux

 

安装docker

安装之前配置docker源

tee /etc/yum.repos.d/docker.repo <<-'EOF'

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

EOF

 

安装:yum -y install docker-engine

启动:/etc/init.d/docker start

设置开机自启:chkconfig docker on

Centos7:systemctl enable docker