daocloud加速器配置

来源:互联网 发布:smtp.qq 端口号 编辑:程序博客网 时间:2024/04/29 07:03

出处:http://www.cnblogs.com/anliven/p/6217418.html

感谢原创作者的分享,如转载有不妥,请联系本人,即刻删除,谢谢!


由于众所周知的原因,从Docker Hub难以高效地下载镜像。
除了使用VPN或代理之外,最为有效的方式就是使用Docker国内镜像。
DaoCloud是首个提供国内免费Docker Hub镜像的团体,可以使用DaoCloud团队提供的Docker Hub Mirror服务。

Docker加速器简介

Docker加速器是 DaoCloud 推出的 Docker Hub Mirror 服务的官方名称。
Docker加速器提供Docker Registry(Docker Hub)在中国的镜像代理服务,为中国用户在国内服务器上缓存诸多镜像。
当用户的Docker设定了--registry-mirror参数后,用户的Docker拉取镜像时,首先去Docker加速器中查找镜像,若命中则说明该镜像已经在Docker加速器中缓存,用户直接从Docker加速器中下载。
若没有命中,则说该镜像还没有被缓存,那么Docker加速器首先会被驱使去Docker Hub中下载该镜像,并进行缓存,最终让用户从Docker加速器中下载该镜像。

Docker加速器使用说明

在DaoCloud注册并登录。
在登录后的页面(https://dashboard.daocloud.io/),点击“加速器”标签,根据新弹出的页面中“配置 Docker 加速器”信息,更改自己的 Docker 配置文件,然后重启Docker,使之生效。
注意:此时,从“配置 Docker 加速器”信息中,我们其实已经得到一个免费的docker镜像地址,类似于“http://abcd1234.m.daocloud.io”。

示例:配置及使用Docker加速器

这里以Linux系统为例。

Linuxcurl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://abcd1234.m.daocloud.io该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。

注意:将http://abcd1234.m.daocloud.io替换为实际的链接。
更多详情请访问文档

配置Docker加速器

[root@CentOS-7 ~]# uname -a Linux CentOS-7 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux[root@CentOS-7 ~]# [root@CentOS-7 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@CentOS-7 ~]# [root@CentOS-7 ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://abcd1234.m.daocloud.ioSuccess.You need to restart docker to take effect: sudo systemctl restart docker [root@CentOS-7 ~]# [root@CentOS-7 ~]# systemctl restart docker[root@CentOS-7 ~]# 

使用Docker加速器拉取镜像

[root@CentOS-7 ~]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE[root@CentOS-7 ~]# [root@CentOS-7 ~]# docker run ubuntuUnable to find image 'ubuntu:latest' locallyTrying to pull repository docker.io/library/ubuntu ... latest: Pulling from docker.io/library/ubuntub3e1c725a85f: Pull complete 4daad8bdde31: Pull complete 63fe8c0068a8: Pull complete 4a70713c436f: Pull complete bd842a2105a8: Pull complete Digest: sha256:dbe36a89ad8daf8bbd2a68f14eab18b969d3f125104da51df6337bbf08d1c8aeStatus: Downloaded newer image for docker.io/ubuntu:latest[root@CentOS-7 ~]# [root@CentOS-7 ~]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZEdocker.io/ubuntu    latest              104bec311bcd        8 days ago          128.9 MB[root@CentOS-7 ~]# 

Action is the antidote to despair! 

本博客欢迎转载和引用,但请保留原作者信息! 
随笔可能存在部分内容来自于网络,并略有修改。文章主要或全部内容来自于网络,并略有修改,如有冒犯,即刻删除。