不灭的焱

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2021-08-27 22:47:20  修改时间:2024-04-15 23:52:21  分类:Docker/K8s  编辑

Docker在默认安装之后,通过命令docker pull 拉取镜像时,默认访问docker hub上的镜像,在国内网络环境下,下载时间较久,所以要配置国内镜像仓库。

1、创建或修改daemon.json

daemon.json 文件路径为:/etc/docker/daemon.json,使用vi或vim打开daemon.json

vim /etc/docker/daemon.json

/etc目录下,可能没有docker文件夹,需要手动创建:mkdir /etc/docker

2、daemon.json配置

直接复制粘贴以下内容:

{
    "registry-mirrors": [
        "https://mirror.ccs.tencentyun.com",
        "https://registry.hub.docker.com",
        "http://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://docker.mirrors.sjtug.sjtu.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}

阿里云也有docker源,但相对麻烦一点,有需要可以按如下操作进行申请:
阿里云容器服务:https://cr.console.aliyun.com/
首页点击“创建我的容器镜像” 得到一个专属的镜像加速地址,类似于“https://1234abcd.mirror.aliyuncs.com”

3、重启docker

根据Linux上安装docker的方式不同,选用对应的重启命令:

systemctl restart docker.service

 


Docker Hub 镜像测速

# 测速前先移除本地的镜像!
$ docker rmi nginx:latest

# 使用 time 统计所花费的总时间。
$ time docker pull nginx:latest

Pulling repository nginx
[...]

real   1m14.078s
user   0m0.176s
sys    0m0.120s

从指定repo拉取镜像

命令格式: library/<image:version>

$ docker pull busybox 

# 指定Repo拉取镜像,等价于:
$ docker pull hub-mirror.c.163.com/library/busybox:latest
$ docker pull docker.io/library/busybox:latest
$ docker pull registry.hub.docker.com/library/busybox:latest

 

 

参考:https://www.cnblogs.com/eddyz/p/17168828.html