TL;DR
In this post I will explain how to set up docker when you are behind corporate proxy.
All Internet tutorials about any technology take assumption that you are not behind a proxy. Working for my client that must use corporate proxy, I spent a lot of working hours discovering how to use docker behind a proxy.
You first need to find out value for corporate proxy. In corporate environment, this could be rather tricky action, because that value is not always publicly known.
- Set docker systemd settings to use proxy.
Use official docker instructions [source]. With this setting, docker daemon nows how to get images from the Internet.
2. Dockerfile.
If you need to tailor your own image, you need to use Dockerfile. In order to enable Dockerfile commands to get stuff from the Internet, you need to set ENV HTTP_PROXY variable.
After FROM directive in Dockerfile, put following settings:
FROM image_name ENV http_proxy <HTTP_PROXY> ENV https_proxy <HTTPS_PROXY>
3. Some tools do not use environment variable http_proxy.
There are some tools that made a wrong design decision where they do not use environment variable http_proxy, but they require that command switch must be used in order to set proxy value.
I broke my teeth on following tools:
- pip
- npm
Here is simple heuristic. If command from Dockerfile gets timeout (usually it appears to hang when it can not get to Internet), consult documentation for this command to find out how to set proxy value.