前言:
鉴于国内网络问题,拉取 Docker 镜像十分缓慢,需要配置加速器来解决。
Linux系统
使用 /etc/docker/daemon.json来配置 Daemon。
Windows系统
使用%programdata%\docker\config\daemon.json来配置 Daemon。
请在该配置文件中加入(没有该文件的话,请先建一个):
{
"registry-mirrors": ["https://xxxx.xxxx.aliyuncs.com"]
}
1.使用阿里云镜像加速器
登录阿里云后,进入控制台,选择容器镜像服务后先启用服务。
2.启用容器镜像服务
3.查看加速器地址
开启镜像加速服务后,进入镜像加速器,选择自己的操作系统,上方会显示自己的加速器地址,复制加速器地址,然后根据自己的操作系统配置镜像加速器。
4.配置镜像加速器
[root@localhost ~]# cat >/etc/docker/daemon.json <<EOF
> {
> "registry-mirrors": ["https://xxxx.xxx.aliyuncs.com"]
> }
> EOF
[root@localhost ~]# systemctl daemon-reload //重启加速器服务
[root@localhost ~]# systemctl restart docker //重启docker服务
5.下载nginx镜像
[root@localhost ~]# docker search nginx //搜索nginx镜像
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 12968 [OK]
[root@localhost ~]# docker pull nginx //下载nginx镜像
Using default tag: latest
latest: Pulling from library/nginx
c499e6d256d6: Extracting [============================> ] 15.34MB/27.09MB
74cda408e262: Download complete
ffadbd415ab7: Download complete
[root@localhost ~]# docker images //查看镜像列表
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest ed21b7a8aee9 4 days ago 127MB
总结:
可以看到nginx镜像已经拉取成功了,这里使用的是阿里云的镜像加速器,当然也可以使用其他的加速服务,在配置镜像加速器的时候,如果系统中没有那些文件,就创建出来配置即可。