卸载旧版本
- 如果之前安装旧版本,需要先卸载:
sudo apt-get remove docker docker-engine docker.io containerd runc
设置仓库
- 更新 apt 包索引:
sudo apt-get update
让 apt 能通过 HTTPS 使用仓库:
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
添加官方的 GPG 密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- 阿里云
sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
- 验证你的密钥:
sudo apt-key fingerprint 0EBFCD88
设置选用哪个版本。
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
test"
- 我选用了 test 版本。
安装
- 更新 apt 包索引
sudo apt-get update
- 开始安装
sudo apt-get install docker-ce docker-ce-cli containerd.io
测试
sudo docker run hello-world
docker ps -a
参考
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script
DaoCloud 的安装脚本
#Ubuntu
curl -sSL https://get.daocloud.io/docker | sh
#CentOS
curl -sSL https://get.daocloud.io/docker | sh
sudo chkconfig docker on
sudo systemctl start docker