有两种方法可选,

1. 修改docker的客户端配置文件~/.docker/config.json
$ cat ~/.docker/config.json

{
    "proxies":
    {
        "default":
        {
            "httpProxy": "http://user:password@your-proxy-server:port",
            "httpsProxy": "http://user:password@your-proxy-server:port",
            "noProxy": "*.test.example.com,.example2.com"
        }
    }
}


2. 运行docker时使用环境变量

环境变量 Dockerfile示例 docker run示例
HTTP_PROXY ENV HTTP_PROXY "http://user:password@your-proxy-server:port" --env HTTP_PROXY="http://user:password@your-proxy-server:port"
HTTPS_PROXY ENV HTTPS_PROXY "http://user:password@your-proxy-server:port" --env HTTPS_PROXY="http://user:password@your-proxy-server:port"
FTP_PROXY ENV FTP_PROXY "http://user:password@your-proxy-server:port" --env FTP_PROXY="http://user:password@your-proxy-server:port"
NO_PROXY ENV NO_PROXY "*.test.example.com,.example2.com" --env NO_PROXY="*.test.example.com,.example2.com"

3. 参考:

https://docs.docker.com/network/proxy/

相关文章:

  • 2021-11-20
  • 2022-01-08
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-07-13
  • 2021-07-13
  • 2022-12-23
相关资源
相似解决方案