Docker maven ClientProtocolException plugin (Windows 10 using the Docker Toolbox)

I am trying to create a docker image using docker-maven-plugin (provided by spotify: https://github.com/spotify/docker-maven-plugin ), but everything is wrong, t really works. First I got this exception:

org.apache.http.conn.HttpHostConnectException: Connect to localhost:2375 

I found out that I need to create env. variable to fix this ( https://github.com/spotify/docker-maven-plugin/issues/135 ):

 set DOCKER_HOST=set DOCKER_HOST=tcp://192.168.99.100:2376 

docker_host

So, after installing this env. variable I keep getting this ClientProtocolException:

 [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.3.258:build (default-cli) on project docker_micro_maven: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.client.ClientProtocolException: The server failed to respond with a valid HTTP response 

I have no idea how I could fix this, any input would be greatly appreciated.

+6
source share
3 answers

You need to configure port forwarding of virtual ports using a host on port 2375:

> VBoxManage modifyvm "default" --natpf1 "guestssh,tcp,,2375,,2376"

guestsh is the name of port forwarding, you can choose a name.

If VBoxManage not recognized, you can replace it with the full path:

"pathVirtualBox \ VBoxManage.exe"

And if you have a problem like "Server could not respond with a valid HTTP response" copy the certificate files from
"% USER% .docker \ machines \ certificates"
in
"% USER% .docker"

docker-maven-plugin read these files in "% USER% .docker" (do not copy directory certificates, just files).

I think we can override the maven properties to replace port 2375 and the certs path, but I haven't found it yet.

+4
source

fixed this:

  <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>0.4.13</version> <configuration> <imageName>yourImageName</imageName> <dockerDirectory>src/main/docker</dockerDirectory> <dockerHost>https://192.168.99.100:2376</dockerHost> <dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> 

Important these two tags:

 <dockerHost>https://192.168.99.100:2376</dockerHost> <dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath> 

I am using dockerfile, which path should you determine using this tag:

 <dockerDirectory>src/main/docker</dockerDirectory> 

Now you can create your own jar and create a docker image through:

mvn package docker: build

+3
source

docker-machine env default

 set DOCKER_HOST=tcp://192.168.99.100:2376 set DOCKER_MACHINE_NAME=default set DOCKER_TLS_VERIFY=1 set DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox set DOCKER_CERT_PATH=C:\Users\panhl-a\.docker\machine\machines\default 
0
source

All Articles