使用阿里云专属加速器加快获取Docker官方镜像的实战

本文档介绍如何使用阿里云专属加速器加快获取Docker官方镜像。

步骤如下:

1.      首先需要有阿里云账号,没有就注册阿里云开发账号:

https://dev.aliyun.com/

 

2.      进入加速器页面:

https://cr.console.aliyun.com/#/accelerator

 

我的已经申请好加速器了。

 

3.      配置(这里只介绍CentOS,其他操作系统上面图中都有描述)

给大家演示的Docker版本号为:1.12.3

[root@dockerc ~]# docker version

Client:

 Version:     1.12.3

 APIversion:  1.24

 Goversion:   go1.6.3

 Gitcommit:   6b644ec

 Built:       

 OS/Arch:     linux/amd64

 

Server:

 Version:     1.12.3

 APIversion:  1.24

 Goversion:   go1.6.3

 Gitcommit:   6b644ec

 Built:       

 OS/Arch:     linux/amd64

 

这里我单独新建一个Docker配置文件/etc/systemd/system/docker.service.d/override.conf,不对默认配置文件/usr/lib/systemd/system/docker.service进行修改。

 

override.conf内容为:

[root@dockerc ~]# cat /etc/systemd/system/docker.service.d/override.conf

[Service]

ExecStart=

ExecStart=/usr/bin/dockerd --registry-mirror=https://xxxxxxxx.mirror.aliyuncs.com -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --storage-driver=devicemapper

 

重新启动Docker:

[root@dockerc ~]# systemctl daemon-reload

[root@dockerc ~]# systemctl  restart docker

 

 

4.      实战

我的环境为VMware虚拟出的CentOS 7.2操作系统,未设置代理时,Docker拉取镜像时出现各种错误,比如:

[root@dockerc ~]# docker pull sonatype/nexus:2.14.1-01

Pulling repository docker.io/sonatype/nexus

Tag 2.14.1-01 not found in repository docker.io/sonatype/nexus

 

再比如:

[root@dockerc ~]# docker pull sonatype/nexus:2.14.1-01

Pulling repository docker.io/sonatype/nexus

Network timed out while trying to connect to https://index.docker.io/v1/repositories/sonatype/nexus/images. You may want to check your internet connection or if you are behind a proxy.

 

不存在或提示需要设置代理,反正是各种错误。

 

我们设置代理并重启Docker后再下载镜像:

[root@dockerc ~]# docker pull sonatype/nexus:2.14.1-01

2.14.1-01: Pulling from sonatype/nexus

8d30e94188e7: Pull complete

a22e963dda76: Pull complete

8a74fcef70b5: Pull complete

c70c01af6d38: Pull complete

0e4055792c32: Pull complete

Digest:sha256:d56a33386ea1b009dd16242b74963ab1e64d0d135642bc920ac009934a6c3e07

Status: Downloaded newer image forsonatype/nexus:2.14.1-01

[root@dockerc ~]# docker pull sonatype/nexus3:3.1.0

3.1.0: Pulling from sonatype/nexus3

 

a3ed95caeb02: Pull complete

ea5ce58b688c: Pull complete

10ad92f0d43a: Pull complete

f7044f591837: Pull complete

d4f38ebc7e0b: Pull complete

6f6f3574285b: Pull complete

Digest:sha256:f339d24bba16c7500e2293f885d6293384cfaa3d5c464526a0969ef3e20ada33

Status: Downloaded newer image for sonatype/nexus3:3.1.0

 

是不是觉得很爽。别爽了,镜像下载完了,开始干活吧。

 

当然,如果你的网络使用翻墙代理那就另说了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值