centos7安装docker1.31

1 首先使用yum 安装docker,yum install docker -y。使用docker -v检查docker是否安装成功

2 因为docker使用了iptables的映射规则,而centos7的防火墙是firewall,需要停用 firewall,安装并设置iptables.

具体命令如下:

systemctl stop firewalld 

&& systemctl disable firewalld 

&& yum -y install iptables-services 

&& systemctl  enable iptables 

&& systemctl  start iptables

3 如果centos7版本的内核比较旧,如我的安装完内核是3.10。需要升级linux内核或者修改配置文件。否则启动docker会出现如下错误

Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Either boot into a newer kernel

or disable selinux in docker (--selinux-enabled=false)

      如果想更改配置文件:执行命令,vi /etc/sysconfig/docker

     

     修改为

     

     B  升级linux内核

      可以使用如下命令   

yum update nss
&& rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
&& rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
&& yum clean all
&& yum --enablerepo=elrepo-kernel install kernel-ml -y
&& grub2-set-default 0

升级完重启一下系统。ok

 

         可以通过cat /proc/version 查看内核版本,我安装完的linux内核是3.10.0

 4  启动docker service命令systemctl start docker,可以通过systemctl status 查看docker状态。

      

 参考:

https://blog.csdn.net/a1010256340/article/details/80106156

https://blog.phpgao.com/update_linux_kernel.html

原文地址:https://www.cnblogs.com/SimpleCode/p/9032690.html