If we just need to pull or push the docker image, it is fine to set up the proxy by system service conf file. But this proxy setting seems don't work when building the Dockerfile. We have tried to modify the /etc/default/docker configuration, but this seems also do not work. By looking a lot of answers from StackOverflow, we finally found the right setting to set the proxy.
docker build --build-arg http_proxy=http://10.239.4.80:913 --build-arg https_proxy=http://10.239.4.80:913 .
10.239.4.80:913 is the proxy address of my company, you may need to change according to your company proxy address and port.
You also can set the proxy in the Dockerfile.
ENV http_proxy 10.239.4.80:913
But this method is not recommended in my opinion, since the end-users may directly connect to the internet rather than by proxy.
Discussion (6)
Didn't work in my laptop :(
```$ sudo docker build --build-arg http_proxy=192.168.100.4:3128/ --build-arg https_proxy=192.168.100.4:3128/ -t thibaut/devdocs .
Sending build context to Docker daemon 18.3MB
Step 1/10 : FROM ruby:2.6.0
Get registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
it work for me, thx~
works for me.
As a reminder: point the proxy server to your linux machine's ip. Don't use localhost because localhost refer to your docker and docker run in an isolated network. Obviously, you don't have a proxy server in it.
Thanks Peter, this actually worked for me.
great.. worked fine.
Thanks.