ubuntu配置Docker-ce | Ubuntu+Docker-ce

Docker.io是老版本,Docker-ce是新的社区版本(Docker-ee是企业版)。在Ubuntu下可以使用 sudo apt install docker.io安装Docker.io。但是Docker.io并不满足现在的一些使用需求,需要装Docker-ce。

0.操作系统

  • Ubuntu Xenial 16.04(LTS)
  • Ubuntu Bionic 18.04(LTS)
  • Ubuntu Focal 20.04(LTS)

1.卸载旧版本

如果有安装docker,docker.io或docker-engine

sudo apt-get remove docker docker-engine docker.io containerd runc

2.安装Docker-ce

2.1更新apt软件包索引并安装软件包以允许apt通过HTTPS使用存储库
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
2.2添加Docker的官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2.3验证Docker的官方GPG密钥
sudo apt-key fingerprint 0EBFCD88

出现9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88即可

2.4设置稳定的存储库
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
2.5安装DOCKER引擎
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
2.6配置与验证Docker
# 一个简单的设置 避免频繁使用sudo
sudo usermod -aG docker $USER


# 启动Docker
sudo systemctl start docker

# 查看Docker状态
sudo systemctl status docker

# 停止Docker
sudo systemctl stop docker

3.Docker镜像加速器

阿里云免费镜像加速器地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors(登录就可以获取自己的加速地址了)

# 根据阿里云官网的教程操作即可 如下
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]	# 这里填入自己的加速地址即可
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

来源https://docs.docker.com/engine/install/ubuntu/本文主要是简化原文档。

猜你喜欢

转载自blog.csdn.net/qq_40759015/article/details/110438476