Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Docker for mac proxy variables through terminal

I am using Docker for mac behind a proxy. I set up the proxy configuration in the Docker GUI under "Proxies" -> "Manual proxy configuration". This lets me download Docker images from the repository behind the proxy.

Next, I set the http_proxy and https_proxy environment variables and I use them in my docker-compose.yml to pass them to the build:

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 don't have to set them twice? Are there any Docker-specific environment variables that I can use?

like image 396
elclanrs Avatar asked Jul 27 '17 03:07

elclanrs


2 Answers

Install proxycap or redsocks and relieve yourself from the annoying proxy errors for all your tools and not just Docker. Proxycap/Redsocks transparently redirect traffic to the specified proxy that you have, so you don't configure any proxy settings anymore.

Update: There is a docker image for redsocks in case you cannot install it on the host machine. https://hub.docker.com/r/ncarlier/redsocks/

like image 142
yamenk Avatar answered Oct 01 '22 16:10

yamenk


If I understood correctly want you want, then you just need to read what's given by docker info:

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

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

like image 32
Metaphox Avatar answered Oct 01 '22 16:10

Metaphox