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

允我心安 提交于 2019-12-08 13:52:43

问题


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:


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>


来源:https://stackoverflow.com/questions/46059403/docker-maven-fabric8-plugin-on-windows-building-image-gives-incompatibility-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!