1.卸载Docker旧版本

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

2.安装 Docker Engine-Community(使用 Docker 仓库进行安装)

  1. 设置仓库
sudo apt-get update
  1. 安装 apt 依赖包,用于通过 HTTPS 来获取仓库
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common
  1. 添加 Docker 的官方 GPG 密钥
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
  1. 设置稳定版仓库
$ sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian \
  $(lsb_release -cs) \
  stable"
  1. 报错(没有报错的话继续步骤7)
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 95, in <module>
    sp = SoftwareProperties(options=options)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 109, in __init__
    self.reload_sourceslist()
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 599, in reload_sourceslist
    self.distro.get_sources(self.sourceslist)    
File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 93, in get_sources
    (self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Deepin/n/a
  1. 解决方法

手动添加源地址:

 sudo vim /etc/apt/sources.list

添加以下语句,保存并退出:

deb [arch=amd64] https://download.docker.com/linux/debian stretch stable

执行以下命令:

sudo apt-get update

输出以下内容,则解决成功:

命中:2 https://community-packages.deepin.com/deepin apricot InRelease                                                                                 
命中:3 https://cdn-package-store6.deepin.com/appstore eagle InRelease                                                                                 
命中:1 http://uos.deepin.cn/printer eagle InRelease                                             
命中:4 https://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch InRelease
正在读取软件包列表... 完成
  1. 安装 Docker Engine-Community
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. 启动Docker
$ systemctl start docker
  1. 显示以下内容则安装启动成功
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

  1. 如果使用 docker 官方仓库,速度会很慢,所以更换国内加速器
    登录阿里云账号,拷贝自己的加速器地址
    在这里插入图片描述
  2. 禁止开机自启
    默认情况下 docker 是开机自启的,如果我们想禁用开机自启,可以通过安装 chkconfig 命令来管理 Deepin 自启项:
# 安装chkconfig
sudo apt-get install chkconfig

# 移除自启
sudo chkconfig --del docker
 
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐