Ubuntu 20.04 LTS 安装 docker(qbit)

卸载旧版本

docker 在发展中产生了很多的名字(docker/docker.io/docker-engine ),当前(2020/5/26)软件包名为 docker-ce(Docker Engine-Community)。可以尝试清理旧版软件:

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

安装依赖包

# 更新索引
sudo apt update
# 安装依赖包
sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加仓库

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

确认 docker 版本

$ sudo apt update
$ apt policy docker-ce
docker-ce:
  Installed: (none)
  Candidate: 5:19.03.9~3-0~ubuntu-focal
  Version table:
     5:19.03.9~3-0~ubuntu-focal 500
        500 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

安装 docker

sudo apt install docker-ce docker-ce-cli containerd.io

查看 docker 状态

sudo systemctl status docker

免 sudo 运行

  • 免 root 运行(rootless)在 v19.03 引入,在 v20.10 GA。
  • 添加并切换用户组

    # 添加用户组
    # $USER 为当前用户,可以换为特定用户名
    sudo usermod -aG docker $USER
    # 切换用户组
    newgrp docker
  • 测试

    docker run hello-world
  • docker rootless 官方文档:https://docs.docker.com/engin...

配置国内镜像源加速

  • 创建或修改 /etc/docker/daemon.json

    {
      "registry-mirrors" : [
      "https://registry.docker-cn.com",
      "https://docker.mirrors.ustc.edu.cn",
      "http://hub-mirror.c.163.com",
      "https://cr.console.aliyun.com/"
    ]
    }
  • 重启 docker

    sudo systemctl restart docker
  • 查看

    $ docker info | grep -E "Registry|http"
    WARNING: No swap limit support
     Registry: https://index.docker.io/v1/
     Registry Mirrors:
    https://registry.docker-cn.com/
    https://docker.mirrors.ustc.edu.cn/
    http://hub-mirror.c.163.com/
    https://cr.console.aliyun.com/
    
本文出自 qbit snap

你可能感兴趣的:(Ubuntu 20.04 LTS 安装 docker(qbit))