docker - Docker build_image无法到达我的本地Maven存储库

标签 docker dockerfile docker-for-mac

嗨,运行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构建的结果:
 ---> 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,并且我的笔记本电脑可以连接。

最佳答案

问题按以下方式解决:https://success.docker.com/article/How_do_I_configure_the_default_bridge_(docker0)_network_for_Docker_Engine_to_a_different_subnet

jetty 桥与我的网络冲突。我们需要在daemon.json中输入

{
    "bip": "172.26.0.1/16"
}

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

关于docker - Docker build_image无法到达我的本地Maven存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48799568/

相关文章:

linux - 在 docker 容器内的命令

image - 用于新提交的Docker镜像的Dockerfile

amazon-web-services - Aws Ecs 中微服务之间的通信

azure - Docker 构建失败并出现 "Service failed to build: COPY failed: no such file or directory"错误

docker - 在 amd64 linux 机器上为 arm32v7 容器运行 docker build 时出错 : standard_init_linux. go:207

docker - 将war文件镜像放入docker容器是一种好习惯吗?

docker - 将ASP.NET Core部署到Azure容器服务(群体模式)

macos - Mac/OS X 上的/var/lib/docker 在哪里

.net - Paths/ASP.NET/Https 和/Microsoft/UserSecrets) 在 mac 上未共享

kubernetes - 使用Kubernetes或Minikube更新到Mac版Docker后,确保套接字安全的最佳方法是什么