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?
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.
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/
Best of my knowledge : it is not possible.
The only idea I get is to use sort of iptable rules (I guess there is similar stuff in mac) that redirect external ip packet to the proxy. It means your docker is clean, you simply activate / deactivate rules if you are behind a proxy or not.
It is not easy, but it is do-able.
链接地址: http://www.djcxy.com/p/96978.html上一篇: 构造函数的Constexpr条件