方法一
修改docker守护进程,在/etc/docker/daemon.json
中添加配置
{
"data-root": "/data/docker-data",
"storage-driver": "overlay2",
"proxies": {
"http-proxy": "socks5://192.168.5.200:7891",
"https-proxy": "socks5://192.168.5.200:7891",
"no-proxy": "*.coding.net,192.168.0.0/8"
}
}
警告
若使用了Mirror,则需要在noProxy为其排除,否则Mirror也会走Proxy
方法二
在配置文件~/.docker/config.json
中新增如下配置
"proxies": {
"default": {
"httpProxy": "socks5://192.168.5.200:7891",
"httpsProxy": "socks5://192.168.5.200:7891",
"noProxy": "*.coding.net,192.168.0.0/24"
}
}
警告
若使用了Mirror,则需要在noProxy为其排除,否则Mirror也会走Proxy
方法三
创建配置文件/etc/systemd/system/docker.service.d/proxy.conf
[Service]
Environment="HTTP_PROXY=socks5://192.168.5.200:7891"
Environment="HTTPS_PROXY=socks5://192.168.5.200:7891"
重启服务
systemctl daemon-reload
systemctl restart docker
文章评论