1. Docker自动安装
在CentOS和Ubuntu上进行Docker的自动安装是相同的。
1.1 阿里云镜像安装
# 使用阿里云镜像
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
1.2 使用国内daocloud一键安装命令
curl -sSL https://get.daocloud.io/docker | sh
2. Ubuntu 手动安装步骤
2.1 卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
2.2 设置Docker仓库
更新索引包
sudo apt-get update
安装apt依赖包,用于通过HTTPS来获取仓库
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
添加Docker官方GPG密钥
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add
# 验证,通过搜索摘要的后8个字符
sudo apt-key fingerprint 0EBFCD88
设置稳定版仓库
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/" \
$(lsb_release -cs) \
"stable"
2.3 安装Docker Engine-Community
更新apt包索引
sudo apt-get update
安装最新版本的 Docker Engine-Community 和 containerd,或者转到下一步安装特定版本
sudo apt-get install docker-ce docker-ce-cli containerd.io
安装特定版本
# 列出docker版本
apt-cache madison docker-ce
# 进行安装
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> contaionerd.io
2.4 测试安装是否成功
sudo docker run hello-world
CentOS Docker 安装见 菜鸟教程