首页 > 解决方案 > docker-ce 19.03.5 在尝试启动从 docker hub 抓取图像的容器时不会使用代理

问题描述

预期行为 I would expect to see traffic trying to hit my proxy server when docker grabs images from docker hub.

实际行为 I see traffic trying to go directly to docker hub and is not using the proxy specified in the environment variable

重现行为的步骤设置代理变量并确保它设置为: echo $HTTP_PROXY 尝试通过指定 HTTP_PROXY 变​​量来使用 golang 运行容器 docker run -e HTTP_PROXY golang:1.9

我也尝试通过在此处创建文件来设置 systemd 配置: /etc/systemd/system/docker.service.d/http-proxy.conf 然后运行 ​​systemctl daemon-reload 然后 service docker restart

docker版本的输出:

Docker version 19.03.5, build 633a0ea838
Output of docker info:

docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.4.0-170-generic
 Operating System: Ubuntu 16.04.6 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 992.1MiB
 Name: cmsp-sand1
 ID: BPFR:QNXD:WVD5:5TXT:AXDQ:YNXT:APCN:U4XS:7OTZ:73NP:JW34:KNSM
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.)
This is running on a virtualbox vagrant VM (ubuntu16.04.6) this nested inside a hyper-v VM running ubuntu 18.04.1

标签: docker

解决方案


我从 systemd http-proxy.conf 文件中删除了 HTTPS_PROXY 设置并修复了它,显然我的代理不支持 tls 连接,所以我不需要 HTTP_PROXY 和 HTTPS_PROXY


推荐阅读