Centos 下安装 Docker-ce

CentOS 7.0, CentOS 7.2:

cat > /etc/yum.repos.d/docker-main.repo << -'EOF' 
[docker-main-repo]
name=Docker main Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
-EOF

yum install docker-engine -y
systemctl start docker

 

CentOS 7.4:

yum install -y yum-utils


yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum
install -y docker-ce


systemctl start docker

cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors":["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com"],
"exec-opts":["native.cgroupdriver=systemd"],
"log-driver":"json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver":"overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF

 

systemctl restart docker

 

注意:这里的服务器系统时间需要设置为中国时区,时间不同可能会导致镜像无法下载,很多人喜欢用虚拟机来做实验,最好把命令放到定时任务中。

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
/usr/sbin/ntpdate ntp1.aliyun.com
crontab -e

添加

*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com > /dev/null 2>&1

 安装指定版本的 docker-ce

# 对应的版本可以在 repo 中找到,https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/

yum
install docker-ce-18.03.1.ce -y
 

相关文章:

  • 2021-12-25
  • 2020-04-25
  • 2021-10-02
  • 2021-11-10
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2021-05-09
  • 2021-05-26
  • 2021-12-31
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-05-23
相关资源
相似解决方案