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鏡像加速

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章