【问题标题】:Docker build_image cannot reach my local maven repoDocker build_image 无法访问我的本地 Maven 仓库
【发布时间】:2018-02-15 03:31:21
【问题描述】:

嗨,正在运行 docker:引擎:Mac 10.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

很明显,您可以看到 docker 正在解析 I.P,并且我的笔记本电脑可以连接。

【问题讨论】:

  • 你能ping通http://xxx.xxx.xxx.xxx:8081给出的远程主机并把结果发送到这里吗?
  • 看我的问题。我更新了信息。
  • 所以你有一个100% packet loss,假设你可以访问其他域,这可能是由于他们的服务器端无法正常工作而发生的。您的系统中是否已有openjdk:8-jdk-alpine?
  • 是的,我可以提取图像,问题是只能访问我的本地 maven 仓库。我认为使用 BUILD_IMAGE 构建的 docker 可能不支持设置 DNS?
  • 我还应该补充一点,wget xxxxxxx 正在解决,只是无法到达它......

标签: docker dockerfile docker-for-mac


【解决方案1】:

问题已解决:https://success.docker.com/article/How_do_I_configure_the_default_bridge_(docker0)_network_for_Docker_Engine_to_a_different_subnet

docker 网桥与我的网络发生冲突。我们需要在 daemon.json 中做一个条目

{
    "bip": "172.26.0.1/16"
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-02
    • 1970-01-01
    • 2015-02-08
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-26
    • 2017-11-10
    相关资源
    最近更新 更多