技术改变生活

博客园 首页 新随笔 联系 订阅 管理

 

[root@localhost ~]# docker image pull centos
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/library/centos/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fcentos%3Apull&service=registry.docker.io: net/http: TLS handshake timeout

解决方案(亲测):

修改docker镜像源:

      docker默认的源为国外官方源,下载速度较慢,可改为国内,加速

方案一

修改或新增 /etc/docker/daemon.json

[root@docker01 ~]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}

[root@docker01 ~]# systemctl restart docker.service

 

方案二

 

      修改或新增 /etc/sysconfig/docker,在OPTIONS变量后追加参数  --registry-mirror=https://docker.mirrors.ustc.edu.cn

 

[root@docker01 ~]# vi /etc/sysconfig/docker
OPTIONS='--selinux-enabled --log-driver=journald --registry-mirror=https://docker.mirrors.ustc.edu.cn'

 

从公网docker hub 拉取(下载)image   pull:拉 
[root@xuegod63 ~]# docker pull docker.io/centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ... 
latest: Pulling from docker.io/library/centosGet https://registry-1.docker.io/v2/library/centos/manifests/sha256:822de5245dc5b659df56dd32795b08ae42db4cc901f3462fc509e91e97132dc0: net/http: TLS handshake timeout 
#报错了,因为网络的问题。 无法连接到dockerhub 下载镜像。 如果你的网络没有问题,你可以下载。
解决:换一个docker下载地址
或: 使用阿里云docker镜像加速,提升pull的速度:
你只需要登录容器Hub服务 https://cr.console.aliyun.com的控制台,使用你的支付宝帐号,第一次登录时,需要设置一个独立的密码,左侧的加速器帮助页面就会显示为你独立分配的加速地址。

 

 

 

 

 

 


网易镜像:
https://c.163.com/hub#/m/home/   #需要先注册登录上,才能打开此站点
 

 

 


[root@xuegod63 ~]# vim  /etc/docker/daemon.json   #改成以下内容
改: {}
为:
{
"registry-mirrors": ["https://e9yneuy4.mirror.aliyuncs.com"]
}
[root@xuegod63 ~]# systemctl daemon-reload
[root@xuegod63 ~]# systemctl restart docker
[root@xuegod63 ~]# docker pull docker.io/centos  #再下载,就可以了。
 
 

 

 

Docker国内源说明:

 

      Docker 官方中国区:https://registry.docker-cn.com

 

      网易:http://hub-mirror.c.163.com

 

      中国科技大学:https://docker.mirrors.ustc.edu.cn

 

      阿里云:https://pee6w651.mirror.aliyuncs.com

 

最终我用下面的方案解决了:

 

进入/etc/docker

 

查看有没有 daemon.json。这是docker默认的配置文件。

 

如果没有新建,如果有,则修改。

 

[root@docker01 ~]# vi daemon.json
{
  "registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]
}

 

 

 

保存退出。

 


重启docker服务

 

[root@docker01 ~]#  systemctl restart docker.service

 

 

 

成功!

 

posted on 2020-02-05 22:22  小阿峰  阅读(22718)  评论(0编辑  收藏  举报