通过终端获取Docker for Mac代理变量 [英] Getting Docker for mac proxy variables through terminal

查看:123
本文介绍了通过终端获取Docker for Mac代理变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代理后面使用Docker for mac。我在Docker GUI的代理->手动代理配置下设置了代理配置。这样一来,我就可以从代理后面的存储库中下载Docker映像。

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.

接下来,我设置 http_proxy https_proxy 环境变量,我在docker-compose.yml中使用它们将它们传递给构建:

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

如何获取通过终端中的Docker GUI设置的变量,而不必两次设置?我可以使用任何特定于Docker的环境变量吗?

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?

推荐答案

如果我正确理解了您想要的,那么您只需要读取 docker info 给出的内容:

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

如果在GUI中设置了这两个,它们将出现在输出的结尾附近。如果未设置,则不会,在我的情况下,没有代理:* .local,169.254 / 16 将会出现。

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.

这篇关于通过终端获取Docker for Mac代理变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆