-
从Ubuntu的仓库直接下载安装(可能不是最新版本):
sudo apt install docker.io
(时间较长)
sudo systemctl start docker
sudo systemctl enable docker
查看是否安装成功:
docker -v
输出
Docker version 17.12.1-ce, build 7390fc6
则安装成功
-
从官方Docker存储库安装Docker
sudo apt update
接下来,安装一些必备软件包,这些软件包允许通过HTTPS使用软件包:
sudo apt 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 -
输出:OK
将Docker存储库添加到APT源:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
可能出现:404 Not Found
接下来,使用新添加的repo中的Docker包更新包数据库:
sudo apt-get update
确保您要从Docker repo而不是默认的Ubuntu 16.04 repo安装:
sudo apt-cache policy docker-ce
输出:(可能版本不同输出不同)
docker-ce: 已安装:(无) 候选: 18.06.1~ce~3-0~ubuntu 版本列表: 18.06.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.06.0~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages 18.03.1~ce~3-0~ubuntu 500 500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
安装Docker:
sudo apt install docker-ce
现在应该安装Docker,守护进程启动,并启用进程启动进程。 检查它是否正在运行:
sudo systemctl status docker
输出:
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
Active: active (running) since Fri 2018-11-02 06:46:06 PDT; 31min ago
Docs: https://docs.docker.com
Main PID: 12203 (dockerd)
Tasks: 30
CGroup: /system.slice/docker.service
├─12203 /usr/bin/dockerd -H fd://
└─12223 docker-containerd --config
/var/run/docker/containerd/contain
Nov 02 06:46:04 ubuntu dockerd[12203]: time="2018-11-02T06:46:04.690178153-07:00
Nov 02 06:46:04 ubuntu dockerd[12203]: time="2018-11-02T06:46:04.690211788-07:00
Nov 02 06:46:04 ubuntu dockerd[12203]: time="2018-11-02T06:46:04.690608135-07:00
Nov 02 06:46:04 ubuntu dockerd[12203]: time="2018-11-02T06:46:04.690629646-07:00
Nov 02 06:46:05 ubuntu dockerd[12203]: time="2018-11-02T06:46:05.569648817-07:00
Nov 02 06:46:05 ubuntu dockerd[12203]: time="2018-11-02T06:46:05.715152669-07:00
Nov 02 06:46:05 ubuntu dockerd[12203]: time="2018-11-02T06:46:05.853855471-07:00
Nov 02 06:46:05 ubuntu dockerd[12203]: time="2018-11-02T06:46:05.853942472-07:00
Nov 02 06:46:06 ubuntu dockerd[12203]: time="2018-11-02T06:46:06.001000723-07:00
Nov 02 06:46:06 ubuntu systemd[1]: Started Docker Application Container Engine.
安装结束
- 参考
Method1
Method2