Linux环境安装Docker

1. 使用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

2. 配置Docker镜像加速器

推荐使用阿里云 容器镜像加速器

容器镜像加速器

容器镜像加速器

通过修改 daemon 配置文件 /etc/docker/daemon.json

 "registry-mirrors":["镜像加速器的加速地址"

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF

# 重启 Docker
systemctl daemon-reload
systemctl restart docker

# 验证配置是否成功
docker info

我的个人博客www.gofy.top

 

原文地址:https://www.cnblogs.com/gaofei200/p/12720256.html