Docker学习之Ubuntu18安装Docker Community最新版本(4)

Ubuntu18安装Docker Community最新版本

Ubuntu系统环境介绍介绍
Ubuntu版本:18.04.1
系统配置:64位
Linux内核:5.3.0-42-generic
官方文档: https://docs.docker.com/install/linux/docker-ce/ubuntu/
关于如何安装docker网上介绍了很多方法, 但是有一些方法是安装的docker旧版本,这样导致在卸载的时候使用新版本的卸载方法,不能卸载成功,今天我们跟着官方文档,按照标准流程安装docker-ce最新版本

第一步:设置apt-get库

  1. 更新Ubuntu源
acestang@acestang:~$ sudo apt-get update
  1. 安装apt-get依赖的软件包,可以通过https使用仓库
acestang@acestang:~$ sudo apt-get install \
>     apt-transport-https \
>     ca-certificates \
>     curl \
>     gnupg-agent \
>     software-properties-common
  1. 添加Docker官方秘钥
acestang@acestang:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#结果显示OK,说明添加成功
OK
  1. 验证现在具有指纹 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88的密钥,通过搜索后8位指纹
acestang@acestang:~$ sudo apt-key fingerprint 0EBFCD88
  1. 使用以下命令设置稳定的Docker库
acestang@acestang:~$ sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease                    
Hit:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease                           
Hit:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease                   
Hit:4 http://linux.teamviewer.com/deb stable InRelease                               
Hit:5 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease                 
Get:6 https://typora.io ./linux/ InRelease [793 B]                                   
Hit:7 https://download.docker.com/linux/ubuntu bionic InRelease                   
Fetched 793 B in 2s (364 B/s)
Reading package lists... Done
W: Conflicting distribution: https://typora.io ./linux/ InRelease (expected ./linux/ but got )

第二部:正式安装Docker

  1. 再次更新Ubuntu源
acestang@acestang:~$ sudo apt-get update
  1. 查看Docker版本
acestang@acestang:~$ sudo apt-cache madison docker-ce
[sudo] password for acestang: 
 docker-ce | 5:19.03.8~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.7~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.6~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.5~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.4~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.3~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.2~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.1~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:19.03.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.9~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.8~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.7~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.6~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.5~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.4~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.3~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.2~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.1~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.3~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.2~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.03.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
  1. 安装最新版本Docker
# 默认安装最新Latest版本
acestang@acestang:~$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# 安装制定版本的命令
acestang@acestang:~$ sudo apt-get install -y docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
    1. 验证Docker是否安装成功
acestang@acestang:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest
#这句话提示已经安装Docker成功
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/

备注:网上安装Docker的博客文档很多,但是作为壹号,还是推荐直接查看官方文档进行安装,毕竟每次版本的更新,都可能有一些小的变动,我们要养成查看官方文档的好习惯
下一篇文章介绍:如何设置Docker镜像加速

原创文章 25 获赞 0 访问量 1814

猜你喜欢

转载自blog.csdn.net/ttf0203/article/details/105106712