Centos7安装Docker脚本

in docker with 0 comment

可以根据需要修改配置和docker版本。

################# docker ###################
# remove old
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
sudo yum remove -y docker-ce docker-ce-cli containerd.io
# reinstall

yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2;

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

#cp /etc/yum.repos.d.back/* /etc/yum.repos.d/

yum install -y docker-ce-19.03.9 docker-ce-cli-19.03.9 containerd.io


mkdir -pv /root/docker/data
if [ ! -d /etc/docker ]; then
   mkdir -pv /etc/docker
fi
cat > /etc/docker/daemon.json <<EOF
{
  "live-restore": true,
  "data-root": "/root/docker/data",
  "exec-opts": [
     "native.cgroupdriver=systemd"
  ],
  "insecure-registries": [
  ],
  "registry-mirrors": ["https://r2otk349.mirror.aliyuncs.com"]
}
EOF

systemctl daemon-reload
systemctl enable docker
systemctl restart docker
systemctl status docker -l
################# docker end ###################