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": ["http://hub-mirror.c.163.com"]
}
-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