Docker
-
下载 docker 安装包
- 服务器支持访问互联网
- 服务器不支持访问互联网
wget http://pdpublic.mingdao.com/private-deployment/offline/common/docker-27.3.1.tgz
# docker 安装包文件下载链接,下载完成后上传到部署服务器
http://pdpublic.mingdao.com/private-deployment/offline/common/docker-27.3.1.tgz -
解压,并将文件移动到二进制文件目录
tar -zxvf docker-27.3.1.tgz
mv -f docker/* /usr/local/bin/
-
创建 docker 配置文件
默认 docker 数据目录在 /data/docker,如果需要修改默认数据目录,请修改
daemon.json
配置文件中 data-root 的值mkdir -p /etc/docker/
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://uvlkeb6d.mirror.aliyuncs.com"],
"data-root": "/data/docker",
"max-concurrent-downloads": 10,
"exec-opts": ["native.cgroupdriver=cgroupfs"],
"storage-driver": "overlay2",
"default-address-pools":[{"base":"172.80.0.0/16","size":24}]
}
EOF -
配置 systemd 管理 docker
cat > /etc/systemd/system/docker.service <<EOF
[Unit]
Description=Docker
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/local/bin/dockerd
ExecReload=/bin/kill -s HUP \$MAINPID
LimitNOFILE=102400
LimitNPROC=infinity
LimitCORE=0
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF -
启动 docker
systemctl daemon-reload && systemctl start docker && systemctl enable docker