How can I make docker-compose pull images using a socks5 proxy?
Asked Answered
C

3

8

I use port-forwarding like this:

ssh -vND 1080 user@server_ip

Question:

How can I pull docker images with socks5?

pulling docker images with the docker pull command already has an answer here. But I want to use docker-compose for pulling images

Centner answered 9/12, 2019 at 10:5 Comment(0)
P
14

You can set the proxy config in the services systemd config (/etc/systemd/system/docker.service.d/http-proxy.conf):

[Service]
Environment="HTTP_PROXY=socks5://127.0.0.1:1080"

docker pull socks proxy

The service config works for docker-compose pull as well: docker-compose pull socks proxy

Parable answered 9/12, 2019 at 11:15 Comment(0)
H
2

If your service is maintained by systemd,set http proxy and https proxy in the service config file,/etc/systemd/system/docker.service.d/proxy.conf:

[Service]
Environment="HTTP_PROXY=socks5://<proxy host>:<port>"
Environment="HTTPS_PROXY=socks5://<proxy host>:<port>"

Then,restart docker service:

systemctl daemon-reload
systemctl restart docker
Hangout answered 7/12, 2021 at 3:36 Comment(0)
L
2

One solution is to edit the docker config file ~/.docker/config.json and add the following entry in the json file.

"proxies": {
   "default": {
     "httpProxy": "socks5://127.0.0.1:1080",
     "httpsProxy": "socks5://127.0.0.1:1080",
     "noProxy": "127.0.0.0/8"
   }
}

In my case the proxy was on localhost port 1080, but this can be changed to any other proxy address.

Lozoya answered 4/7, 2023 at 7:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.