1. 安裝方式
你可以根據(jù)需要,,以不同的方式安裝docker CE
大部分用戶設(shè)置repositories來安裝docker CE,,這種方法易于安裝和升級,,也是官方建議的方式,。
一些用戶下載deb包,,手動安裝和管理升級,。這種方式適用于沒有互聯(lián)網(wǎng)連接的情況。
在開發(fā)測試環(huán)境,,一些用戶選擇使用自動化腳本安裝docker,。
2. 安裝實踐
2.1 使用repository安裝(推薦)
在一臺新主機上首次安裝docker CE時,你需要設(shè)置docker repository,,之后你就可以安裝和升級docker了,。
- 通過https,允許apt使用repository安裝軟件包
# sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
- 通過搜索指紋的8個字符,,驗證key的指紋:9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
# 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) <docker@>
sub 4096R/F273FCD8 2017-02-22
- 使用以下命令設(shè)置穩(wěn)定的repository,。
即使想從最新或測試的repository安裝構(gòu)建,你也需要穩(wěn)定的repository,。要添加最新或測試repository,,請在下面的命令中的stable之后添加edge或test(或兩者)。
# add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# apt-get update
# apt-get install -y docker-ce
或者安裝一個指定版本的Docker CE
在repository中列出可用的版本號,,然后選擇安裝,。Docke守護進程將會自動啟動,。
# apt-cache madison docker-ce
# apt-get install -y docker-ce=18.03.0~ce-0~ubuntu
# docker run hello-world
首先更新apt包索引,然后按照上述步驟選擇指定版本升級安裝
# apt-get update
2.2 使用deb包安裝
如果不能使用repository安裝,,那么你需要下載.deb包,,然后手動安裝。每次升級docker CE,,你都需要下載相應(yīng).deb包,。
轉(zhuǎn)到 https://download./linux/ubuntu/dists/,選擇/artful/pool/stable/,,選擇amd64,、armhf、ppc64el或者s390x,,選擇對應(yīng)版本下載
Docker守護進程自動啟動
# dpkg -i /path/to/package.deb
# docker run hello-world
下載.deb包,,然后覆蓋安裝
2.3 使用腳本安裝(不推薦)
在多個操作系統(tǒng)中,可以使用腳本自動安裝edge版本的docker,,不是stable版本,。在運行腳本之前,請仔細檢查,。
$ curl -fsSL get. -o get-docker.sh
$ sudo sh get-docker.sh
<output truncated>
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker your-user
Remember to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group grants the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs./engine/security/security/#docker-daemon-attack-surface
for more information.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
如果你使用腳本安裝docker CE,則可以直接使用包管理器升級docker,。
3. 卸載docker CE
# apt-get purge docker-ce
Images,、containers、volumes和定制的配置文件不會自動清理,。你需要手動刪除所有的images,、containers、volumes和配置文件
# rm -rf /var/lib/docker
4. 原文地址
https://docs./install/linux/docker-ce/ubuntu/#upgrade-docker-after-using-the-convenience-script
|