下载安装脚本
1
   | curl -fsSL https://get.docker.com -o get-docker.sh
   | 
 
设置安装版本(nightly / test / stable)
设置下载镜像源
具体参考安装机器的 repo
阿里云公网
1
   | export DOWNLOAD_URL=https://mirrors.aliyun.com/docker-ce
   | 
 
阿里云内网
1
   | export DOWNLOAD_URL=http://mirrors.cloud.aliyuncs.com/docker-ce
   | 
 
设置 repo 文件名
1
   | export REPO_FILE=docker-ce.repo
   | 
 
安装
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   | mkdir -p /etc/docker cat <<EOF >  /etc/docker/daemon.json {     "exec-opts": [         "native.cgroupdriver=systemd"     ],     "registry-mirrors": [         "http://f1361db2.m.daocloud.io"     ],     "log-driver": "json-file",     "log-opts": {         "max-size": "100m"     },     "storage-driver": "overlay2",     "storage-opts": [         "overlay2.override_kernel_check=true"     ] } EOF
   | 
 
运行
1 2 3 4
   | systemctl enable docker.service systemctl start docker.service
  docker version
   | 
 
其他
腾讯云镜像 repo 内地址仍是 download.docker.com ,所以使用该脚本没有效果,但是可以使用阿里云公网下载完成后替换镜像源
1 2
   |  sed -i 's|https://mirrors.aliyun.com|http://mirrors.tencentyun.com|' /etc/yum.repos.d/docker-ce.repo
 
  |