Docker 不 运行 使用代理

Docker don't run with proxy

我需要你的帮助,

我的docker不运行我的企业,我不知道该怎么办

kaue default # docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pulling fs layer 
docker: error pulling image configuration: Get https://production.cloudflare.docker.com/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18ee64e6d59cf2eafcdddf9cec2364dfe129fe0af75f1b0194e0c96/data?verify=1528483070-KGbywXnskgTKu5B9AuTdFPQdYjs%3D: x509: certificate signed by unknown authority.
See 'docker run --help'

.

我有一个 Windows 7,并且在我的工作中经过身份验证的代理...

在 运行 执行 docker 运行 命令之前在您的环境中设置代理...

设置HTTPS_PROXY=http://user:password@proxy_name_or_ip:proxy_port

例如 设置 HTTPS_PROXY=http://myusername:Password1@proxy.local:8080

对于 windows 上的 docker,按照 these steps 配置代理变量:

在 powershell 中对 HTTP_PROXY 和 HTTPS_PROXY 执行以下操作:

[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://username:password@proxy:port/", [EnvironmentVariableTarget]::Machine)

设置变量后,使用 powershell 重新启动服务:

Restart-Service docker

编辑:对于使用 systemd Docker 的 Linux 本机安装,请按照 these steps 配置您的代理:

  1. Create a systemd drop-in directory for the docker service:
$ sudo mkdir -p /etc/systemd/system/docker.service.d
  1. Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

Or, if you are behind an HTTPS proxy server, create a file called /etc/systemd/system/docker.service.d/https-proxy.conf that adds the HTTPS_PROXY environment variable:

[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"
  1. If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:
[Service]    
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

Or, if you are behind an HTTPS proxy server:

[Service]    
Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"
  1. Flush changes:
$ sudo systemctl daemon-reload
  1. Restart Docker:
$ sudo systemctl restart docker
  1. Verify that the configuration has been loaded:
$ systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/

Or, if you are behind an HTTPS proxy server:

$ systemctl show --property=Environment docker
Environment=HTTPS_PROXY=https://proxy.example.com:443/

对于密码中的特殊字符,您可以use unicode对字符进行编码:

如果您的原始密码是:F@o:o!B#ar$

Unicode 等价物是:F%40o%3Ao%21B%23ar%24