Docker maven fabric8 plugin (on Windows): building image gives incompatibility issues ?

2.6k views Asked by At

Via Maven I would like to build a Docker image from a Springboot project. I run: mvn clean package docker:build Issue:

ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.21.0:build (default-cli) on project spring-boot-docker: Execution default-cli of goal io.fabric8:docker-maven-plugin:0.21.0:build failed: An API incompatibility was encountered while executing io.
fabric8:docker-maven-plugin:0.21.0:build: java.lang.UnsatisfiedLinkError: unknown
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>io.fabric8:docker-maven-plugin:0.21.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/Johan/.m2/repository/io/fabric8/docker-maven-plugin/0.21.0/docker-maven-plugin-0.21.0.jar
Etc

The maven pom.xml file contains:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <docker.image.prefix>springframeworkguru</docker.image.prefix>
    <docker.image.name>springbootdocker</docker.image.name>
    <docker.host.url>unix:///var/run/docker.sock</docker.host.url>
</properties>

The build plugin section contains:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.21.0</version>
            <configuration>
                <dockerHost>${docker.host.url}</dockerHost>
                <verbose>true</verbose>
                <images>
                    <image>
                        <name>${docker.image.prefix}/${docker.image.name}</name>
                        <build>
                            <dockerFileDir>${project.basedir}/src/main/docker/</dockerFileDir>
                            <assembly>
                                <descriptorRef>artifact</descriptorRef>
                            </assembly>
                            <tags>
                                <tag>latest</tag>
                                <tag>${project.version}</tag>
                            </tags>
                        </build>
                    </image>
                </images>
            </configuration>
        </plugin>
    </plugins>
</build>

As suggested, I removed my maven repository, which did not help. Using other dockerHost values (like http://127.0.0.1:2375) did not help.

I really hope you can help!

1

There are 1 answers

0
tm1701 On BEST ANSWER

This is the solution on Windows 7, 8 and 10 Home:

  • Find the docker machine environment variables. Go to the docker (shell) and type: docker-machine env. The docker host and certification path are important.
  • Add the following properties to your pom.xml (maven) file:
    • <docker.host.url>(e.g.) tcp://192.168.99.100:2376</docker.host.url>
    • <docker.host.certPath>(e.g.) a path</docker.host.certPath>
  • In your build plugin add just after configuration
    • <dockerHost>${docker.host.url}</dockerHost>
    • <certPath>${docker.host.certPath}</certPath>