Docker / Boot2Docker:为OS X上的docker设置HTTP / HTTPS代理 [英] Docker/Boot2Docker: Set HTTP/HTTPS proxies for docker on OS X
问题描述
简而言之:如何在Mac OS和X上设置Docker的HTTP / HTTPS代理?
In short: How can I set the HTTP/HTTPS proxies for Docker on Mac OS X?
详细:
我在代理服务器后面的Mac OS X上运行Docker(1.12)我遵循安装说明并安装了boot2docker。如果我从我的网络内部Docker注册表中提取,这可以正常工作。
I run Docker (1.12) on Mac OS X behind a proxy. I followed the installation instructions and installed boot2docker. This is working fine if I pull from my network-internal Docker registry.
但是,从docker.io拉出时,我收到以下错误:
However, I get the following error when pulling from docker.io:
machine:~ me$ docker run ubuntu echo hello world
Unable to find image 'ubuntu' locally
Pulling repository ubuntu
2014/06/30 13:23:26 Get https://index.docker.io/v1/repositories/ubuntu/images:
dial tcp: lookup index.docker.io: no such host
注1 : DOCKER_HOST
, http_proxy
和 https_proxy
在环境中可用(运行 env
显示所有三个。)
Note 1: DOCKER_HOST
, http_proxy
and https_proxy
are available in the environment (running env
displays all three).
注2 :我在其他帖子中阅读了当守护程序运行不正常时发生此错误。但是, docker版本
不会显示任何问题。此外,我可以从我的网络内部Docker注册表中拉出并运行图像。
Note 2: I read in other posts that this error occurs when the daemon is not running properly. However, docker version
doesn't show any problems. Moreover, I can pull and run images pulled from my network-internal Docker registry.
注3 :我可以设置Docker Red Hat Linux (RHEL)。我不得不将代理信息添加到 / etc / sysconfig / docker
中。我读到Ubuntu上有一个类似的文件( /etc/init/docker.conf
)。但是,在Mac OS X上找不到Docker(或boot2docker?)的文件。
Note 3: I was able to set up Docker on Red Hat Linux (RHEL). I had to add the proxy information to /etc/sysconfig/docker
. I read that there is a similar file on Ubuntu (/etc/init/docker.conf
). However, I could not find that file for Docker (or boot2docker?) on Mac OS X.
推荐答案
配置文件您需要修改不会在您的OS X文件系统上,它们将被附加到作为本地Docker服务器的Tiny Core Linux VM。
The config files you need to modify won't be on your OS X file system, they'll be attached to the Tiny Core Linux VM which acts as your local Docker server.
配置代理,首先从应用程序启动Boot2docker。一旦开始,得到一个终端窗口和ssh进入虚拟机:
To configure the proxy for that, first start Boot2docker from Applications. Once it's started, get a terminal window and ssh into the VM:
bash-3.2$ boot2docker ssh
Warning: Permanently added '[localhost]:2022' (RSA) to the list of known hosts.
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
boot2docker: 1.0.1
master : cad5ece - Fri Jun 20 02:03:40 UTC 2014
docker@boot2docker:~$
现在创建/修改/ var / lib / boot2docker / :
Now create/modify /var/lib/boot2docker/profile to set proxy info:
docker@boot2docker:~$ sudo vi /var/lib/boot2docker/profile
Tinycore需要代理信息如下:protocol:// ip:port
为了安全起见,我为两者设置代理HTTP和HTTPS。
Tinycore needs the proxy info as follows: protocol://ip:port
To be safe I set proxies for both HTTP and HTTPS.
export HTTP_PROXY=http://your.proxy.name:8080
export HTTPS_PROXY=http://your.proxy.name:8080
现在,您可以重新启动VM Docker服务并退出VM。
Now you can restart the VM docker service and exit the VM.
docker@boot2docker:~$ sudo /etc/init.d/docker restart
docker@boot2docker:~$ exit
Connection to localhost closed.
You should be able to run the client against the VM instance now.
bash-3.2$ docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Official Ubuntu base image 356
stackbrew/ubuntu Official Ubuntu base image 39
crashsystems/gitlab-docker A trusted, regularly updated build of GitL...
此更改通过VM重新启动持久化。您只需要执行一次。
This change is persisted through VM restarts. You should only need to do it once.
对于记录,VirtualBox具有代理的全局首选项设置,但没有我尝试的那样工作。
For the record, VirtualBox has a global preference setting for proxies but nothing I tried there would work.
这篇关于Docker / Boot2Docker:为OS X上的docker设置HTTP / HTTPS代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!