docker-maven-plugin icon indicating copy to clipboard operation
docker-maven-plugin copied to clipboard

buildx support builds unwanted image with OS and architecture unkown/unknown

Open obfischer opened this issue 1 year ago • 4 comments

Description

Unfortunately we hat do remove the Docker Maven Plugin from our project, as the support of buildx lead to unwanted additional images in the OCI index.

Each image we build had a tiny additional image in its OCI index listet without architecture and OS inforamation. Furthermore Trivy was unable to scan it because of errors.

As a successfull Trivy scan is required for an image to promoted to the next stage, I had to decide to kick out the plugin and to replace it by calls to docker ... via the Maven Exec Plugin.

Here is a screenshot from Harbor grafik

Info

  • docker-maven-plugin version : 0.43.0
  • Maven version (mvn -v) :
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /Users/plx/tooling/apache-maven-3.8.6
Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

  • Docker version :
  • If it's a bug, how to reproduce : 24.0.2
  • If it's a feature request, what is your use case :
  • Sample project : [GitHub Clone URL]

As this is a company internal project, I can't provide the hole project, but here is the plugin configuration:

<plugin>
    <groupId>io.fabric8</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <configuration>
        <images>
            <image>
                <name>harbor.acme.com/service/%a:%l</name>
                <build>
                    <buildx>
                        <platforms>
                            <platform>${pbid.docker.plattform}</platform>
                        </platforms>
                    </buildx>
                    <tags>
                        <tag>${project.version}</tag>
                    </tags>
                    <filter>@</filter>
                    <dockerFile>Dockerfile</dockerFile>
                    <contextDir>${project.basedir}</contextDir>
                </build>
            </image>
        </images>
    </configuration>
    <executions>
        <execution>
            <id>build-oci-images-for-service</id>
            <phase>package</phase>
            <goals>
                <goal>build</goal>
                <goal>tag</goal>
            </goals>
        </execution>
        <execution>
            <id>push-oci-image-to-registry</id>
            <phase>deploy</phase>
            <goals>
                <goal>push</goal>
            </goals>
        </execution>
    </executions>
</plugin>

obfischer avatar Dec 11 '23 18:12 obfischer

Interesting. I'm not so deep in the buildx integration, which is a recent addition. Do you require to use buildx or would the traditional way of building the image also good enough ? (which relies on the architecture of the build system though).

What buildx command are using concrete with maven exec (including command line options). thanks!

rhuss avatar Dec 14 '23 14:12 rhuss

Hi @rhuss, the traditional way would be enough for our use case. We switched to buildx as we had problems with the traditional way, as you called it.

One of my team mates replaced the Docker Maven Plugin by the jib plugin, as we where under high pressure.

Can I help you with other information?

obfischer avatar Dec 20 '23 20:12 obfischer

@obfischer : It's quite strange because other people are also using buildx and no one has reported a problem like this. Could you please provide these?

What buildx command are using concrete with maven exec (including command line options)

  1. What command was DMP trying to execute?

  2. What is value of pbid.docker.plattform?

  3. What docker version are you using?

rohanKanojia avatar Dec 21 '23 04:12 rohanKanojia

Hi @rohanKanojia, this was a freelancing project and the project finished this week. So I don't have access to the code. But the problem was reproducable on Mac, Windows and Linux.

As I can't provide any additional information as the project ended, it is fine for me to close this issue 😢

obfischer avatar Dec 23 '23 08:12 obfischer