一、在一台新主机上首次安装docker CE时,你需要设置docker repository,之后你就可以安装和升级docker了。

通过https,允许apt使用repository安装软件包

apt-get install -y apt-transport-https ca-certificates curl software-properties-common

二、添加Docker官方GPG key

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -

三、添加最新或测试repository,请在下面的命令中的stable之后添加edge或test(或两者)

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

四、更新apt包索引

apt-get update

五、安装最新版本的Docker CE

apt-get install -y docker-ce

在repository中列出可用的版本号,然后选择安装。Docke守护进程将会自动启动。

apt-cache madison docker-ce

apt-get install -y docker-ce=18.03.0~ce-0~ubuntu