I'm trying to pull images through a socks5 proxy. I've started the socks5 proxy on port 8888 like this:

ssh -NC -D 8888 parham@***.***.**

However, when I run docker-compose like this, it is evident that it's not using the environment variable:

$ ALL_PROXY=socks5:// docker-compose up

How can I make Docker pull images through this proxy?

  • 1
    docker-compose doesn't pull images. It tells Docker to pull the images. – Michael Hampton Nov 28 '15 at 18:37

Looks like this feature has been recently added to docker, particularly in version 1.11.0. Though there isn't enough documentation about its usage, setting the ALL_PROXY environment variable should work, according to this comment.

$ export ALL_PROXY=socks5://localhost:port 
$ docker pull image

I'm not sure about docker-compose at the moment. If your primary aim is to speed up the download process using socks5, you might be able to achieve the purpose by manually pulling images using docker pull before finally running docker-compose up.

  • It works for docker-compose too. Thanks – mcrunix Oct 21 '18 at 20:12

@nikhilweee's answer above is missing a crucial point.

The proxy used for image-pull is taken from the environment of dockerd. There is presently no way to change it without restarting dockerd.

I have filed moby issue #37335 about it, because I wanted to use a specific proxy for a single pull command, but not in general.


In Docker 17.07 and higher, you can also use json file for proxy configuration:

       $ vim ~/.docker/config.json

                  "httpProxy": "",
                  "httpsProxy": ""

        $  docker pull ubuntu:18.04
        $  docker-compose build

More info in official docs.

And in addition to use Socks, You can forward Socks to HTTP by using privoxy:

    $ sudo apt install -y privoxy
    $ sudo vim /etc/privoxy/config
              forward-socks5 /  .
              forward-socks4a / .
              forward-socks5t             / .
              forward         192.168.*.*/     .
              forward            10.*.*.*/     .
              forward           127.*.*.*/     .
              forward           localhost/     .
    $ sudo service privoxy restart

More info in official docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.