如何为 Docker 配置代理?(Linux)

如何为 Docker 配置代理?(Linux)

为 docker 拉取镜像设置代理

/etc/systemd/system/docker.service.d/ 创建 http-proxy.conf

1
2
3
4
5
#/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://localhost:port/"
Environment="HTTPS_PROXY=http://localhost:port/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"

为 docker container 实例设置代理

~/.docker/ 创建 conig.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ~/.docker/conig.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "token"
}
},
"proxies": {
"default": {
"httpProxy": "http://localhost:port",
"httpsProxy": "http://localhost:port",
"noProxy": "localhost,127.0.0.1"
}
}
}

如何为 Docker 配置代理?(Linux)
https://tedding.dev/2025/03/03/1955ac419e0.html
作者
TED.DING
发布于
2025年3月3日
许可协议