安裝官方鏈接:https://docs.docker.com/install/linux/docker-ce/ubuntu/
首先卸載舊版本
$ sudo apt-get remove docker docker-engine docker.io
安裝 Docker CE
其實有三種方式,選擇推薦的第一種。三種方式如下:
-
Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
-
Some users download the DEB package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
-
In testing and development environments, some users choose to use automatedconvenience scripts to install Docker.
設置REPOSITORY
1.
$ sudo apt-get update
2.
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
3.添加信任 Docker 的 GPG 公鑰 (Docker’s official GPG key):
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
完成後會輸出OK,然後輸入
$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <[email protected]>
sub 4096R/F273FCD8 2017-02-22
4.設置stable repository.如果要添加 edge or test repository, 可以在如下指令的“stable
”後面添加 edge
or test
(or both)。默認不加,直接運行。
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
安裝 DOCKER CE
-
$ sudo apt-get update
-
安裝默認最新版本的Docker CE;如果想安裝其他版本的,可跳過這步執行下一步。
$ sudo apt-get install docker-ce
-
如果要安裝特殊版本的Docker CE,則執行:
a. 列出可安裝的版本:
$ apt-cache madison docker-ce docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
b.輸入安裝版本的完整名稱,如,
docker-ce=18.03.0~ce-0~ubuntu
.$ sudo apt-get install docker-ce=<VERSION>
-
確認Docker CE是否已完整安裝by running the
hello-world
image.$ sudo docker run hello-world
這條指令將下載一張測試圖片,並輸出這個圖片的信息。下載完後大概看到“Hello,from Docker!”的信息,說明安裝完成了。
另外,Docker需要sudo才能運行,因爲用戶組權限不夠,若想“拋掉”sudo,可以接着如下教程去做(時間有限暫未做,待更):
https://docs.docker.com/install/linux/linux-postinstall/
(For more:安裝官方鏈接:https://docs.docker.com/install/linux/docker-ce/ubuntu/)
Docker CE介紹
現在Docker改爲基於YY.MM的版本(像Ubuntu),用戶可以選擇Stable(發佈較慢)或者Edge(發佈較快)版本。
-
Docker Engine改爲Docker CE(社區版)
它包含了CLI客戶端、後臺進程/服務以及API。用戶像以前以同樣的方式獲取。 -
Docker Data Center改爲Docker EE(企業版)
在Docker三個定價層增加了額外的支付產品和支持 -
這些修改並不影響Docker Compose以及Docker Machine
-
Docker版本現在基於YY.MM
使用基於月份的發行版本,17.03 的第一版就指向17.03.0,如果有bug/安全修復需要發佈,那麼將會指向17.03.1等等。 -
"Edge"與"Stable"兩個版本發行
Edge版本每月發佈,提供一個月支持。
Stable版本每季度發佈,提供4個月支持。
你可以通過Docker EE訂閱 延長Stable版本支持以及補丁修復。