我的ubuntu 版本是 18.04.1   ,刚才安装 好的,干净的系统,如有同学之前安装过,必须卸载后,才能重新安装

具体安装步骤如下

一、设置仓库

     为了设置仓库,需要有几个前置步骤,完成之后才是真正设置仓库,具体如下

  1、更新 apt 包索引。

  sudo apt-get update

   执行结果如下

    

2、安装 apt 依赖包,用于通过HTTPS来获取仓库:

sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

  执行结果如下

   

 3、添加 Docker 的官方 GPG 密钥:  

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

  执行结果如下

  结果为ok,表示成功了

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 这个官方密钥,可验证刚才设置的结果

具体如下

 sudo apt-key fingerprint 0EBFCD88      (注: sudo apt-key fingerprint 后面是官方密钥后面的8位

 

执行结果如下

这个表示验证成功

 

4、设置稳定版仓库

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

执行结果如下

    

二、安装 Docker Engine-Community

   1、更新 apt 包索引

    sudo apt-get update

       执行结果如下

      

  2、安装最新版本的 Docker Engine-Community 和 containerd ,或者转到下一步安装特定版本:

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

执行结果如下

root@zs:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aufs-tools cgroupfs-mount libltdl7 pigz
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli libltdl7 pigz
0 upgraded, 7 newly installed, 0 to remove and 24 not upgraded.
Need to get 85.8 MB of archives.
After this operation, 385 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 aufs-tools amd64 1:4.9+20170918-1ubuntu1 [104 kB]
Get:3 https://download.docker.com/linux/ubuntu bionic/stable amd64 containerd.io amd64 1.2.13-1 [20.1 MB]
Get:4 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6,320 B]
Get:5 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libltdl7 amd64 2.4.6-2 [38.8 kB]
Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce-cli amd64 5:19.03.8~3-0~ubuntu-bionic [42.6 MB]
Get:7 https://download.docker.com/linux/ubuntu bionic/stable amd64 docker-ce amd64 5:19.03.8~3-0~ubuntu-bionic [22.9 MB]
Fetched 85.8 MB in 45s (1,890 kB/s)                                                                       
Selecting previously unselected package pigz.
(Reading database ... 66987 files and directories currently installed.)
Preparing to unpack .../0-pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../1-aufs-tools_1%3a4.9+20170918-1ubuntu1_amd64.deb ...
Unpacking aufs-tools (1:4.9+20170918-1ubuntu1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../2-cgroupfs-mount_1.4_all.deb ...
Unpacking cgroupfs-mount (1.4) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../3-containerd.io_1.2.13-1_amd64.deb ...
Unpacking containerd.io (1.2.13-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../4-docker-ce-cli_5%3a19.03.8~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce-cli (5:19.03.8~3-0~ubuntu-bionic) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../5-docker-ce_5%3a19.03.8~3-0~ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:19.03.8~3-0~ubuntu-bionic) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../6-libltdl7_2.4.6-2_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-2) ...
Setting up aufs-tools (1:4.9+20170918-1ubuntu1) ...
Setting up containerd.io (1.2.13-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up cgroupfs-mount (1.4) ...
Setting up libltdl7:amd64 (2.4.6-2) ...
Setting up docker-ce-cli (5:19.03.8~3-0~ubuntu-bionic) ...
Setting up pigz (2.4-1) ...
Setting up docker-ce (5:19.03.8~3-0~ubuntu-bionic) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.38) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...

 

3、列出可用版本(注:这里安装特定版本,所以安装前需要列出可用版本

     apt-cache madison docker-ce

执行结果如下:

   

 

4、安装

   这里选择 5:19.03.8~3-0~ubuntu-bionic 列表中第一个版本,这只是个人建议,这个版本不是最新也不是最旧,其实使用起来差距不大, 

sudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-bionic docker-ce-cli=5:18.09.0~3-0~ubuntu-bionic containerd.io

执行结果如下

5、测试是否成功

     sudo docker run hello-world

执行结果如下,说明安装成功了

 

 

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐