Docker has many useful repository and up-to-date. If we have direct connection that’s no matter we can pull package directly from docker repository. What if we develop behind a proxy/company proxy? Usually, it is fine to put proxy in ENV system variable to pull or push the docker image. But this settings 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 and searching around the nets, we finally found the right setting to set the proxy by adding an argument to set the proxy.
docker build --build-arg http_proxy=http://proxy-ip-address:port --build-arg https_proxy=http://proxy-ip-address:port .
proxy-ip-address:port is the proxy address of your company, you may need to change according to your company proxy address and port.
You also can set the proxy inside the Dockerfile.
ENV http_proxy=http://proxy-ip-address:port ENV https_proxy=http://proxy-ip-address:port