安裝Docker

用設置 Docker 的鏡像倉庫並從中進行安裝

前期準備

更新包

 $ sudo apt-get update

安裝軟件包,以允許 apt 通過 HTTPS 使用鏡像倉庫:

 $ sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     software-properties-common

添加 Docker 的官方 GPG 密鑰:

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

驗證密鑰是否爲:9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

 $ sudo apt-key fingerprint 0EBFCD88

設置 stable 鏡像倉庫,不同的處理器架構不同,詳情參見官網,我使用的:

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

開始安裝

更新包

 $ sudo apt-get update

安裝最新版本的 Docker CE

 $ sudo apt-get install docker-ce

安裝特定版本的 Docker CE

輸出可用版本

 $ apt-cache madison docker-ce

選擇特定版本

VERSION爲版本號
 $ sudo apt-get install docker-ce=<VERSION>

檢驗安裝

sudo docker run hello-world

輸出一下信息爲正常:

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