Skip to content

docker-py does not set the proxy env variables #2199

@little-dude

Description

@little-dude

I have a ~/.docker/config.json with some a proxy configuration:

 {
     "auths": {
         "my-registry.net": {
             "auth": "XXXXXXXXXXX"
         }
     },
     "HttpHeaders": {
         "User-Agent": "Docker-Client/18.09.0-ce (linux)"
     },
     "proxies": {
         "default": {
             "httpProxy": "http://my-proxy.com:8000",
             "noProxy": "localhost,localaddress,.localdomain.com,/var/run/docker.sock"
         }
     }
 }

This config is taken into account when I use the CLI client:

~ $ docker run -it busybox /bin/sh -c 'env | grep -i proxy'
HTTP_PROXY=http://my-proxy.com:8000
http_proxy=http://my-proxy.com:8000
no_proxy=localhost,localaddress,.localdomain.com,/var/run/docker.sock
NO_PROXY=localhost,localaddress,.localdomain.com,/var/run/docker.sock

But with the python client:

In [1]: import docker

In [2]: client = docker.from_env()

In [3]: client.containers.run('busybox', '/bin/sh -c "env|grep -i proxy || true"', tty=True, stdin_open=True)
Out[3]: b''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions