Ubuntu Xenial 16.04 版本安装 Docker。

删掉老版本

1
$ sudo apt-get remove docker docker-engine docker.io

使用仓库安装

允许 apt 使用 HTTPS 仓库

1
2
3
4
5
6
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

添加 Docker 官方 GPG 秘钥

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

添加仓库

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

安装 Docker ce

安装最新稳定版

1
2
$ sudo apt-get update
$ sudo apt-get install docker-ce

查看所有可安装版本

1
2
3
$ apt-cache madison docker-ce

docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

安装指定版本

1
$ sudo apt-get install docker-ce=18.03.0.ce

运行 helloworld 镜像

1
$ sudo docker run hello-world
03-17 03:50