Linux系统在线安装docker任意版本完整教程

1.卸载docker

systemctl stop docker
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine \
                  docker-ce


rm -rf /etc/docker
rm -rf /run/docker
rm -rf /var/lib/dockershim
rm -rf /var/lib/docker

2.安装docker

systemctl stop firewalld # 关闭
systemctl disable firewalld # 禁止开机启动防火墙
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
yum install -y yum-utils device-mapper-persistent-data lvm2 wget curl

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    

#yum list docker-ce --showduplicates | sort -r #查看yum仓库中可以安装的docker版本
#yum -y install docker-ce-18.06.1.ce-3.el7 #安装指定的版本
yum -y install docker-ce docker-ce-cli containerd.io #安装最新docker
systemctl enable docker
systemctl start docker
docker --version

cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://qj799ren.mirror.aliyuncs.com"],
  "insecure-registries": ["0.0.0.0/0"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
systemctl restart docker
systemctl status docker

希望能帮助到您,也还以随手一个点赞,谢谢~

你可能感兴趣的:(docker容器相关,linux,docker,linux,运维)