docker拉取镜像失败提示:

Hint: Some lines were ellipsized, use -l to show in full.
[root@docker-master-79100 ~]# docker pull registry:2.7
Trying to pull repository docker.io/library/registry ... 
Get https://registry-1.docker.io/v2/library/registry/manifests/2.7: net/http: TLS handshake timeout
[root@docker-master-79100 ~]# docker run -d -p 80:5000 --restart always --name registry \
>   -v /opt/data/registry:/var/lib/registry registry:2.7
Unable to find image 'registry:2.7' locally
Trying to pull repository docker.io/library/registry ... 
/usr/bin/docker-current: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout.
See '/usr/bin/docker-current run --help'.
[root@docker-master-79100 ~]#  vi /etc/sysconfig/docker
[root@docker-master-79100 ~]#  vim /etc/sysconfig/docker
[root@docker-master-79100 ~]# docker pull registry:2.7
Trying to pull repository docker.io/library/registry ... 
2.7: Pulling from docker.io/library/registry

解决方案:
修改docker镜像源:
docker默认的源为国外官方源,下载速度较慢,可改为国内,加速
方案一

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

复制代码
[root@docker-master-79100 ~]# vi /etc/docker/daemon.json
{
“registry-mirrors”: [“http://hub-mirror.c.163.com”]
}

[root@docker-master-79100 ~]# systemctl restart docker.service
复制代码

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

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

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@docker-master-79100 ~]# vi daemon.json
{
“registry-mirrors”: [“https://registry.docker-cn.com”,“http://hub-mirror.c.163.com”]
}

保存退出。

重启docker服务

[root@docker-master-79100 ~]# systemctl restart docker.service