docker使用http_proxy配置代理

钢铁知识库,一个学习python爬虫、数据分析的知识库。人生苦短,快用python。

在内网服务器中,docker经常需要下载拉取镜像,但由于没有网络要么只能手动导入镜像包,又或者通过http_proxy代理到其它服务器下载。

解决方法:

增加http-proxy.conf配置文件,正确配置好代理服务器后重启docker服务即可

NO_PROXY后面接不需要代理的仓库的域名或者IP,以英文逗号结尾

shell 复制代码
mkdir -p /etc/systemd/system/docker.service.d/http-proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://10.124.130.19:123"
Environment="HTTPS_PROXY=http://10.124.130.19:123"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF

## 重载并重启服务
systemctl daemon-reload && systemctl restart docker

再次执行可以看到顺序拉取到镜像。

另外:如果是containerd需要使用proxy代理,配置原理也是一样。

shell 复制代码
mkdir -p /etc/systemd/system/containerd.service.d/
tee /etc/systemd/system/containerd.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://10.124.130.19:123"
Environment="HTTPS_PROXY=http://10.124.130.19:123"
EOF

## 重启生效
systemctl daemon-reload && systemctl restart containerd

参考链接:

https://docs.docker.com/config/daemon/systemd/

相关推荐
虎头金猫2 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS2 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
玉&心2 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing2 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
赵文宇(温玉)2 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
guo_wen_qiang2 天前
上传本地镜像到harbor中
docker·容器·持续部署
羑悻的小杀马特2 天前
Dockerfile 全景指南:从入门编写dockerfile到生产环境镜像优化实战,一步步带你从啃透制作指令到镜像制作落地!
docker·dockerfile·镜像制作
XUEYUAN52122 天前
ASN 自治系统号风控:平台如何通过 IP 所属自治域批量识别代理流量
python·网络协议·http·网络安全·socks5
BianHuanShiZhe2 天前
docker常见命令
docker
正经教主2 天前
【FDE系列】阶段2:Day 43:Docker Compose — 多容器一键编排
人工智能·docker·fde