Centos7安装Docker脚本

可以根据需要修改配置和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;

# 国内访问docker官方镜像可能会有异常,可以替换为aliyun镜像源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/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 ###################
0 0 投票数
Article Rating
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x