Getting Docker for mac proxy variables via terminal

I use Docker for mac for proxy. I configured the proxy configuration in the Docker GUI under "Proxies" → "Manual Proxy Settings". This allows you to download Docker images from the repository behind a proxy.

Then I set the environment http_proxy and https_proxy , and I use them in my docker-compose.yml file to pass them to the assembly:

 services: app: build: context: . args: http_proxy: $http_proxy https_proxy: $https_proxy 

How can I get the variables that I set through the Docker GUI in the terminal, so I do not need to set them twice? Are there any environment variables for Docker that I can use?

+8
docker docker-compose
source share
4 answers

If I understand correctly what you want, then you just need to read what docker info given:

 ❯ docker info | grep Proxy Http Proxy: http://localhost:3128 Https Proxy: http://localhost:3128 

If these two options are set in the GUI, they will appear near the end of the output. If they are not installed, they will not, and in my case, No Proxy: *.local, 169.254/16 will appear instead No Proxy: *.local, 169.254/16 .

+1
source share

Install proxycap or redsocks and free yourself from annoying proxy errors for all your tools, not just Docker. Proxycap / Redsocks transparently redirect traffic to the specified proxy server, so you no longer configure the proxy server settings.

Update : For red-eye there is an image of dockers if you cannot install it on the host machine. https://hub.docker.com/r/ncarlier/redsocks/

+4
source share

As far as I know, this is not possible.

The only idea I get is to use iptable rules (I think there are similar things in mac) that redirect the external ip packet to the proxy server. This means that your docker is clean, you simply activate / deactivate the rules if you are behind a proxy server or not.

It is not easy, but it is valid.

0
source share

Either export them, or you can use the right side in the script.

 export http_proxy=$(docker info | grep 'Http Proxy' | cut -f2 -d:) export https_proxy=$(docker info | grep 'Https Proxy' | cut -f2 -d:) 
0
source share

All Articles