docker代理仓库配置

背景

        国内docker官方镜像仓库无法访问,可通过配置代理仓库的方式拉取拉取需要的镜像

docker


1、编辑配置文件:vim /etc/docker/daemon.json  

                                                                                          
{                                                                                                                                        
"registry-mirrors": [                                                                                                                    
        "https://dockerproxy.com",                                                                                                       
        "https://docker.chenby.cn",                                                                                                      
        "https://dockerpull.com",                                                                                                        
        "https://dockerhub.jobcher.com",                                                                                                 
        "https://docker.mirrors.ustc.edu.cn",                                                                                            
        "https://hub.uuuadc.top",                                                                                                        
        "https://mirror.baidubce.com",                                                                                                   
        "https://mirror.ccs.tencentyun.com",                                                                                             
        "https://docker.m.daocloud.io",                                                                                                  
        "https://docker.nju.edu.cn",                                                                                                     
        "https://docker.mirrors.ustc.edu.cn",                                                                                            
        "https://hus-mirror.c.163.com",                                                                                                  
        "https://dockerhub.azk8s.cn",                                                                                                    
        "https://registry.cn-hangzhou.aliyuncs.com"                                                                                      
    ]                                                                                                                                    
} 

2、重启docker:systemctl restart docker

3、验证

containerd

 1、config.toml 文件: vim /etc/containerd/ config.toml

2、添加 registry-mirrors 配置

[plugins."io.containerd.grpc.v1.cri".registry]
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
    [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
      endpoint = [
        "https://dockerproxy.com",
        "https://docker.chenby.cn",
        "https://dockerpull.com",
        "https://dockerhub.jobcher.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://hub.uuuadc.top",
        "https://mirror.baidubce.com",
        "https://mirror.ccs.tencentyun.com",
        "https://docker.m.daocloud.io",
        "https://docker.nju.edu.cn",
        "https://docker.mirrors.ustc.edu.cn",
        "https://hus-mirror.c.163.com",
        "https://dockerhub.azk8s.cn",
        "https://registry.cn-hangzhou.aliyuncs.com"
      ]

3、重启containerd:systemctl restart  containerd

4、验证

Docker镜像仓库代理配置通常是针对那些企业环境或者是受限网络环境下,需要通过特定的代理服务器才能访问外部的Docker Hub或其他私有 registry。以下是常见的配置步骤: 1. **使用环境变量**: - 对于命令行工具 `docker`,可以在启动时传递 `-e` 参数设置代理,例如: ``` docker config set --global http_proxy http://proxy.example.com:8080 docker config set --global https_proxy http://proxy.example.com:8080 ``` - 也可以编辑`~/.docker/config.json` 文件手动添加代理配置。 2. **使用 Dockerfile **: 如果你在构建自己的镜像,可以在 `Dockerfile` 中设置代理,比如: ```Dockerfile RUN apt-get update && \ apt-get install -y apt-transport-https ca-certificates curl software-properties-common && \ export http_proxy=http://proxy.example.com:8080 \ export https_proxy=http://proxy.example.com:8080 \ curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null ``` 3. **使用系统代理**(仅限Linux): 只需确保系统全局代理设置正确,比如在Ubuntu中修改 `/etc/environment` 或 `/etc/profile` 文件,或者通过 `systemd` 或其他系统管理工具配置代理。 请注意,配置代理后需要重启Docker服务让其生效,并确保你的代理服务器支持HTTPS(因为大多数registry都是HTTPS的)。如果代理仍然不可用,可能是代理服务器设置有问题或防火墙阻止了特定的请求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值