Docker for windows10系统下,解决docker-maven-plugin打包项目报Connect failed的问题

博主入坑docker,想模拟集群和高并发环境。在使用docker - maven - plugin打包测试项目时遇到问题,尝试网上多种解决方案均无效。最后在docker/settings的general标签下发现提示,打开被禁止的localhost:2375访问方式后,问题解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近刚刚入坑docker,想利用docker模拟一下集群环境,高并发环境。

然后跟着教程一通操作,都没啥大问题,当使用docker-maven-plugin打包一个测试项目的时候 ,坑出现了。

[INFO] Building image mavendemo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.855 s
[INFO] Finished at: 2019-03-18T17:26:57+08:00
[INFO] Final Memory: 29M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project testdocker: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect -> [Help 1]
[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/MojoExecutionException

对于一个中二程序员,能够做到的第一反应就是迅速报度娘的大腿,但是网上给出了诸如:

1)更改插件版本号

2)显式添加<dockerHostPort>

3)查看docker服务是否开启

4)自己电脑没装docker。。。。。

等各种问题解决方案,试了一遍都不起作用,遂很纳闷,万能的度娘怎么又一次倒下了。。。

正当无聊之时,打开docker/settings,发挥自己390分四级成绩的英语水平,看到了general标签下一个偌大的英文提示:

我这没及格的英语成绩竟然看懂了这段话的意思,大致意思就是 禁止了localhost:2375这种low的访问方式,问你是否打开。

这还用问么,兄弟们,挑上吧。

遂再在idea中,执行docker:build命令:

[INFO] Building image mavendemo
Step 1/5 : FROM openjdk:8-jdk-alpine

 ---> e9ea51023687
Step 2/5 : VOLUME /tmp

 ---> Using cache
 ---> faa470c2c267
Step 3/5 : ARG JAR_FILE

 ---> Using cache
 ---> 4258dc86535a
Step 4/5 : COPY ${JAR_FILE} testdocker-0.0.1-SNAPSHOT.jar.jar

 ---> 8db1b3fb6046
Step 5/5 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/testdocker-0.0.1-SNAPSHOT.jar.jar"]

 ---> Running in 792057a8b6a4
Removing intermediate container 792057a8b6a4
 ---> be606782801c
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built be606782801c
Successfully tagged mavendemo:latest
[INFO] Built mavendemo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.540 s
[INFO] Finished at: 2019-03-18T17:33:54+08:00
[INFO] Final Memory: 32M/218M
[INFO] ------------------------------------------------------------------------

大成,搞定。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值