使用Docker build的时候,会发现pulling某些组件的时候非常慢,甚至出现Timeout的情况,那么此时我们就需要将官方的源替换为国内的源,来提升速度。

编辑/etc/sysconfig/docker文件

1
vim /etc/sysconfig/docker 

将other_args的value补全,目前看来163的源还是蛮好使的,当然阿里云也有提供的。

1
2
3
4
5
6
7
8
9
10
11
12
DOCKER_CERT_PATH=/etc/docker

# Resolves: rhbz#1176302 (docker issue #407)
DOCKER_NOWARN_KERNEL_VERSION=1

# Location used for temporary files, such as those created by
# # docker load and build operations. Default is /var/lib/docker/tmp
# # Can be overriden by setting the following environment variable.
# # DOCKER_TMPDIR=/var/tmp
#
other_args="--registry-mirror=http://hub-mirror.c.163.com"
#other_args="--registry-mirror=https://docker.mirrors.ustc.edu.cn"

重启docker

1
service docker restart

至此,使用sudo docker build -t showdoc ./的时候就快很多了。