Docker build_image无法访问我当地的maven repo

时间:2018-02-15 03:31:21

标签: docker dockerfile docker-for-mac

运行docker:引擎:Mac 12.12.6上的17.12.0-ce

我正在使用build_image功能。

FROM openjdk:8-jdk-alpine AS BUILD_IMAGE

ENV APP_ENVIROMENT=dev
ENV APP_RUNTIME=docker
ENV BUILD_HOME=/build

COPY . $BUILD_HOME
WORKDIR $BUILD_HOME
RUN wget http://xxx.xxx.xxx.xxx:8081

获得以下错误。我非常确定可以通过笔记本电脑/ wifi和VPN访问服务器

...
removing intermediate container e5519d15a106
 ---> b3a3dd24343f
Step 7/16 : RUN wget http://xxx.xxx.xxx.xxx:8081
 ---> Running in 49fdabef0923
Connecting to xxx.xxx.xxx.xxx:8081 (xxx.xxx.xxx.xxx:8081)
wget: can't connect to remote host (xxx.xxx.xxx.xxx): Host is unreachable

看起来像DNS问题我的/etc/resolv.conf非常好,而且我非常确定机器是可以访问的。看起来网络上的某些机器可以访问,而其他机器也没有。

我可以用

进行测试
RUN ping xxx.xxx.xxx.xxx

结果:

PING xxxxxx.mydomain.com (xxx.xxx.xxx.xxx): 56 data bytes

--- xxxxxx.mydomain.com ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
The command '/bin/sh -c ping -c 4 xxxxxx.mydomain.com' returned a non-zero code: 1

更新。添加名称以明确。

FROM openjdk:8-jdk-alpine AS BUILD_IMAGE

ENV APP_ENVIROMENT=dev
ENV APP_RUNTIME=docker
ENV BUILD_HOME=/build

COPY . $BUILD_HOME
WORKDIR $BUILD_HOME
RUN wget http://myserver.domain.net:8081

docker build的结果:

 ---> 76c263fb4490
Step 7/15 : RUN wget http://myserver.domain.net:8081
 ---> Running in ef2b13c77b91
Connecting to myserver.domain.net:8081 (10.0.0.1:8081) <-- I.P redacted to protect the inocent. :p
wget: can't connect to remote host (10.0.0.1): Host is unreachable
The command '/bin/sh -c wget http://myserver.domain.net:8081' returned a non-zero code: 1

从我的控制台......

wget http://myserver.domain.net:8081                                                                                      
--2018-02-15 10:36:44--  http://myserver.domain.net:8081/
Resolving myserver.domain.net... 10.0.0.1
Connecting to myserver.domain.net|10.0.0.1|:8081... connected.
HTTP request sent, awaiting response... 200 OK

显然,你可以看到码头正在解析I.P并且我的笔记本电脑可以连接。

1 个答案:

答案 0 :(得分:1)

问题按照https://success.docker.com/article/How_do_I_configure_the_default_bridge_(docker0)_network_for_Docker_Engine_to_a_different_subnet

解决

docker bridge与我的网络冲突。我们需要在daemon.json

中创建一个条目
{
    "bip": "172.26.0.1/16"
}

您可以使用任何适合您的值。