boot2docker:没有路由到主机

dwj*_*ton 2 proxy virtualbox docker boot2docker docker-toolbox

我在让Windows 10的Docker Toolbox在公司代理后面工作方面遇到麻烦。

我无法使docker登录或docker运行正常工作,所以这是我已完成的调试工作。

我在虚拟机中创建了一个普通的ubuntu机。

在主机上,我启动在端口8000上运行的简单服务器。

在ubuntu中:

$ curl 10.0.2.2:8000
$ [it retrieves the html being served]

$ curl www.google.com 
$ curl (7) Failed to connect to www.google.com port 80: Connection refused
$ export http_proxy=http://my-proxy:3128
$ curl www.google.com
$ [302 HTTP response from google]
Run Code Online (Sandbox Code Playgroud)

在boot2docker上:

$ curl 10.0.2.2:8000
$ [it retrieves the html being served]

$ curl www.google.com 
$ curl (7) Failed to connect to www.google.com port 80: Connection refused
$ export http_proxy=http://my-proxy:3128
$ curl www.google.com
$ curl: (7) Failed to connect to my-proxy:3128: No route to host
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

dwj*_*ton 5

好的,我终于解决了这个问题。

问题是公司代理与默认Docker VM网桥位于同一子网中。(即172.17.xx)。

只是一个快速的解决方法-您可以通过在Docker VM中进行更改来解决此问题。

$ docker-machine ssh mydockervm

$ ifconfig docker0 172.18.0.1 netmask 255.255.0.0
Run Code Online (Sandbox Code Playgroud)