镜像代理

使用方法一

原拉取镜像命令:

    
        docker pull library/alpine:latest
    

加速拉取镜像命令:

    
        docker pull {domain}/library/alpine:latest # 说明:library 代表官方镜像,如果是某个用户的镜像就把
        library 替换为镜像的用户名 # 将{domain}替换为上面URL
    

使用方法二

键设置镜像加速:修改文件 /etc/docker/daemon.json(如果不存在则创建)

    
        vi /etc/docker/daemon.json
    

修改JSON文件 更改为以下内容 然后保存

    
        { "registry-mirrors": [ "https://hub.nat.tf", "https://hub1.nat.tf",
        "https://hub2.nat.tf" ] }
    

在里面填上代理域名即可,可以多个

重载systemd管理守护进程配置文件

    
        systemctl daemon-reload
    

重启 Docker 服务

    
        systemctl restart docker
    

使用方法三

为了加速镜像拉取,使用以下命令设置 registry mirror

    
        sudo tee /etc/docker/daemon.json <<EOF { "registry-mirrors":
        [ "https://hub.nat.tf", "https://hub1.nat.tf", "https://hub2.nat.tf"
        ] } EOF复制代码
    

重载systemd管理守护进程配置文件

    
        sudo systemctl daemon-reload复制代码
    

重启 Docker 服务

    
        sudo systemctl restart docker
    

转载自:

镜像加速

Docker Hub 国内可用镜像【长期更新】