国内镜像源安装Docker

1.卸载原有版本

sudo apt-get remove docker docker-engine docker-ce docker.io

如果需要删除所有镜像,容器和卷(第一次安装请忽略):

sudo rm -rf /var/lib/docker

备注:apt-get remove会保留软件的配置文件如果想删除请执行以下操作

查看相关软件包是否有残余:

dpkg -l | grep docker

使用purage清除配置文件:

sudo apt-get purge docker-ce

2.更新索引包

sudo apt-get update

如果在 update 的时候一直使用的是download.docker.com 国外地址

删除 docker.list 即可

rm -rf /etc/apt/sources.list.d/docker.list

3.安装添加使用 HTTPS 传输的软件包

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

4.添加软件源的GPG密钥(本人选择的中科大)

中科大:

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

阿里云:

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

官方源:

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

5.向 source.list 中添加Docker软件源(本人选择的中科大)

中科大源:

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

阿里源:

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

官方源:

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

6.再次更新索引包

sudo apt-get update

若想直接安装最新版本执行以下命令即可

sudo apt-get install docker-ce
  • 11
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值