扩大
缩小

Docker 配置国内镜像

前言

当我们使用Docker pull 拉取镜像时,有时候因网络问题,导致获取镜像报错,如下 :Error response from daemon:Get https://registry-1.codker.io

解决方案

方案一、通过修改host文件指定registry-1.docker.io 解析到可用IP

(1)通过dig @114.114.114.114 registry-1.docker.io找到可用IP

(2)尝试修改/etc/hosts强制registry-1.docker.io相关的域名解析到其它可用IP

34.232.31.24 registry-1.docker.io

方案二、使用Docker国内镜像,推荐使用DaoCloud提供的镜像,链接:https://www.daocloud.io/mirror#accelerator-doc(推荐)

sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档

然后重启docker服务,即可

sudo systemctl restart docker

  

posted @ 2019-07-09 00:12  戈多编程  阅读(5658)  评论(0编辑  收藏  举报