我想在docker中开发。所以我使用Maven码头工人。这是dockerfile:
FROM maven:3.5.4
MAINTAINER xxx <xxx@xxx.com>
COPY . /app
WORKDIR /app
RUN mvn clean compile
CMD mvn spring-boot:run
但是有错误
Building webapp
Step 1/6 : FROM maven:3.5.4
---> 745b8a8c4bc7
Step 2/6 : MAINTAINER xxx <xxx@xxx.com>
---> Using cache
---> 86bfe1b29459
Step 3/6 : COPY . /app
---> Using cache
---> 2013b90d35bb
Step 4/6 : WORKDIR /app
---> Using cache
---> c735cc45bcd7
Step 5/6 : RUN mvn clean compile
---> Running in 5a9db90f7b13
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.0.0.RELEASE/spring-boot-starter-parent-2.0.0.RELEASE.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for io.github.xxx:spring-boot-my-demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE from/to central (https://repo.maven.apache.org/maven2): Invalid argument or cannot assign requested address and 'parent.relativePath' points at no local POM @ line 14, column 10
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project io.github.xxx:spring-boot-my-demo:0.0.1-SNAPSHOT (/app/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for io.github.xxx:spring-boot-my-demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.RELEASE from/to central (https://repo.maven.apache.org/maven2): Invalid argument or cannot assign requested address and 'parent.relativePath' points at no local POM @ line 14, column 10 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
ERROR: Service 'webapp' failed to build: The command '/bin/sh -c mvn clean compile' returned a non-zero code: 1
我进入码头并运行mvn clean compile -X
:
...
Caused by: java.net.SocketException: Invalid argument or cannot assign requested address
at java.net.PlainSocketImpl.socketConnect (Native Method)
at java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:392)
at java.net.Socket.connect (Socket.java:589)
如果我使用curl
直接获取pom:
root@faee9f5ca168:/app# curl https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.0.0.RELEASE/spring-boot-starter-parent-2.0.0.RELEASE.pom
curl: (7) Couldn't connect to server
但是它在我的主机上运行良好。
并且卷曲其他页面在docker中可以正常工作。我只是无法连接到Maven存储库。谁能帮我吗?