Reputation: 2966
Integrate Docker with Maven Docker Maven Plugin. I had a problem getting the Docker Run through Maven, on window 10 home machine. Build Failure with the following trace.
DOCKER> Cannot create docker access object [Cannot extract API version from
server https://192.168.99.100:2376 :
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target]
[INFO]
Failed to execute goal io.fabric8:docker-maven-plugin:0.21.0:build (default-
cli) on project fleetman: Cannot create docker access object: Cannot extract
API version from server https://192.168.99.100:2376 :
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target -> [Help 1]
[ERROR]
Upvotes: 4
Views: 9741
Reputation: 2966
If you are on window 10 home the solution is:
We are making clean package docker:build as goal
First get the environment variable of your docker installation
$ docker-machine env
You will get something like this
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\vimal\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
This DOCKER_CERT_PATH is already in your machine, you can verify the folder content that has the CA certificates, already generated during installation, nothing to do further.
You have to only add the entries into your POM file, let us see...
<!-- DMP Docker Maven Plugin https://dmp.fabric8.io/ -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.21.0</version>
<configuration>
<!-- <dockerHost>http://127.0.0.1:2375</dockerHost> for window 10 pro-->
<!-- this is for Mac and Amazon Linux -->
<!-- <dockerHost>unix:///var/run/docker.sock</dockerHost> -->
<dockerHost>tcp://192.168.99.100:2376</dockerHost>
<verbose>true</verbose>
<images>
<image>
<name>vimalkrishna/abc-app</name>
<build>
<dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
<tags>
<tag>latest</tag>
</tags>
</build>
</image>
</images>
<certPath>C:\Users\vimal\.docker\machine\machines\default</certPath>
</configuration>
</plugin>
</plugins>
You can copy paste above to your POM and change the XXX of your machine. Only below 2 entries are what you get from env need to be adjusted. Dockertoolkit(Window 10 home) needs 192.168.99.100 unlike 127.0.0.1 of pro version of window 10
<name>vimalkrishna/abc-app</name>
<dockerHost>tcp://192.168.99.100:2376</dockerHost>
<certPath>C:\Users\XXX\.docker\machine\machines\default</certPath>
Thats all, The build will succeed. Put your user and password in local config file
Important! The location of the Dickerfile in your application is
<dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
Means create a folder docker inside src/main/
Upvotes: 5