卸载旧版本
apt-get remove docker docker-engine docker.io containerd runc
使用 APT 安装
# 更新数据源
apt-get update
# 安装所需依赖
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# 安装 GPG 证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 新增数据源
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 更新并安装 Docker CE
apt-get update && apt-get install -y docker-ce
验证安装是否成功
docker version
配置Docker镜像加速:以阿里云加速器为例
通过修改 daemon 配置文件 /etc/docker/daemon.json
来使用加速器
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["你的镜像加速网址"]
}
EOF
# 重启 Docker
systemctl daemon-reload
systemctl restart docker
验证配置是否成功
docker info
# 输出如下
文档整理于李卫明老师的笔记