maven package docker:build - connection refused

2020-05-31 23:47发布

I am trying to directly build a docker image with maven with mvn package docker:build.

Docker is running and docker ps shows me my containers, so I assume that everything is running correctly. I do get the following error though:

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.3:build (default-cli) on project reservierung: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: o rg.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 ->

My first approach was that since I am working on windows I need to call the docker-machine ip address instead of localhost, but that also didn't work. I am kind of at a loss here, because I assume that it's something simple that I am doing wrong, but I cannot find anything about the connection refused error when docker is (seemingly) running properly.

I am sorry if this is trivial.

10条回答
你好瞎i
2楼-- · 2020-06-01 00:12

On MacOs, I just set the environment variables as shown by

docker-machine env

When running the build from an IDE, make sure these variables are properly set.

查看更多
乱世女痞
3楼-- · 2020-06-01 00:13

update maven docker plugin to latest version 1.2.0. This solves the problem.

查看更多
等我变得足够好
4楼-- · 2020-06-01 00:18

If docker is running of Docker for Windows, then below things need to be completed: 1. Open Docker Settings 2. Enable the checkbox - Expose daemon on tcp://localhost:2375 without TLS

Normally, docker opens up port 2376 for docker client but for legacy or other application connect using 2375 port using TCP. If you are using com.spotify it depends upon version also. The latest com.spotify plugin with latest docker working correctly else need to define a variable that tells the plugin to get the hostname from specified environment variable.

To set the hostname manually for the docker set the variable into the environment variable list: DOCKER_HOST="tcp://127.0.00:2376"

It will work for localhost, if docker is running on another machine then set the ip of the same machine.

查看更多
The star\"
5楼-- · 2020-06-01 00:22

Try to run 'docker-machine ls' to check for the IP, if it's not a localhost address, you will need a dockerHost tag in your plugin configuration. ex: <dockerHost>https://192.168.99.100:2376</dockerHost>

newest version of the plugin is 0.4.1 not 0.2.3

查看更多
放我归山
6楼-- · 2020-06-01 00:24

On Windows with Docker/Hyper-V this occurred to me with com.spotify:docker-maven-plugin:1.0.0. There is a discussion about this on another forum, where they advise to turn on enter image description here

in docker Settings/General Tab. It worked for me.

查看更多
Bombasti
7楼-- · 2020-06-01 00:25

In ubuntu 16.04, I solved it with:

DOCKER_HOST=unix:///var/run/docker.sock mvn clean install 
查看更多
登录 后发表回答