Closed brightzheng100 closed 8 years ago
Well, I finally figured it out by some more retries.
The key points could be summarized as below:
DOCKER_OPTS="--insecure-registry 192.168.56.118:5000 -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"
<dockerHost>http://192.168.56.118:4243</dockerHost>
For those who are still struggling on similar issues.
Sounds like the root issue is that the plugin did not know how to communicate with your docker daemon as DOCKER_HOST environment variable or <dockerHost>
was not set. I don't think you needed to add more interfaces/ports for the docker daemon to listen to in order to accomplish that.
Also, be careful about exposing the docker daemon port publicly.
Anyway, should we make it documented on the mandatory setting of <dockerHost>
?
@brightzheng100 I believe it already is: https://github.com/spotify/docker-maven-plugin#setup
@mattnworb thanks for pointing that out but based on my experiment this info sounds NOT sufficient.
Please correct me if I'm wrong as I verified it again but failed:
dockerHost
setting in my pom.xmlThen I got "Host name may not be null" error again, as below:
[INFO] Building image 192.168.56.118:5000/devops/springboot-jersey-swagger
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.134 s
[INFO] Finished at: 2016-10-05T03:21:20+00:00
[INFO] Final Memory: 38M/91M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default) on project springboot-jersey-swagger: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.lang.IllegalArgumentException: Host name may not be null -> [Help 1]
DOCKER_HOST=tcp:192.168.56.118:4243
looks to be incorrectly formatted - I think you would want DOCKER_HOST=tcp://192.168.56.118:4243
You're right, my bad. I tried below approaches, either of which could work fine:
dockerHost
explicitly in pom.xml -- which should be recommended in this plugin's doc as it's a Maven plugin, to avoid extra work;Thanks for your prompt support. You and your team are doing a really good job!
Description
I'm running Jenkins+Maven with this plugin in a customized Docker image. But I got "Host name may not be null" exception while running the Maven build job.
So I docker-entered into the container and switched to the Jenkins workspace to run commands directly. All went well, as below:
How to reproduce
pom.xml:
Maven build goals in Jenkins: -X package docker:build
What do you expect
An image should be built and stored in local Docker repository which would be pushed to private Docker Registry later on (e.g. by using goals of "-X package docker:build -DpushImage")
Software:
$ docker --version Docker version 1.11.0, build 4dc5990
$ mvn --version Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00) Maven home: /opt/maven Java version: 1.8.0_102, vendor: Oracle Corporation Java home: /opt/jdk/jdk1.8.0_102/jre Default locale: en_SG, platform encoding: UTF-8 OS name: "linux", version: "3.16.0-30-generic", arch: "amd64", family: "unix"
Full backtrace