开始安装
由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:
更新apt包索引:
安装以下包以使apt可以通过HTTPS使用存储库(repository):
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
添加Docker官方的GPG密钥:
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-- 使用下面的命令来设置stable存储库:
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-- 再次更新一下apt包索引:
-- 安装最新版本的Docker CE:
-- 在生产系统上,可能会需要应该安装一个特定版本的Docker CE,而不是总是使用最新版本:
-- 列出可用的版本:
# apt-cache madison docker-ce
选择要安装的特定版本,第二列是版本字符串,第三列是存储库名称,它指示包来自哪个存储库
以及扩展它的稳定性级别。要安装一个特定的版本,将版本字符串附加到包名中,并通过等号(=)分隔它们:
# apt-get install docker-ce=<VERSION>
登录 Docker
-- 启动 docker 并查看状态
配置加速器
-- 因为docker hub是在国外的,所以我们获取镜像很慢,所以一般建议价格加速器本人采用阿里云的
-- 打开 开发者平台 – 管理中心 – 加速器 https://dev.aliyun.com/search.html .
--可以看到 “您的专属加速器地址” 即 https://xxxxxxx.mirror.aliyuncs.com .
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker