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

Can't clean all dangling images.

Open lin-mt opened this issue 2 years ago • 4 comments

Description

if Dockerfile like this, after run docker:build, it can't auto clean all dangling iamges.

FROM ubuntu:22.04  as builder

WORKDIR /application
COPY ./target/application.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM ubuntu:22.04
WORKDIR /application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]

Info

  • docker-maven-plugin version : v0.43.4
  • Maven version (mvn -v) :
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: C:\Users\...
Java version: 17.0.9, vendor: Amazon.com Inc., runtime: C:\Users\...\.jdks\corretto-17.0.9
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
  • Docker version :
  • If it's a bug, how to reproduce :
  • If it's a feature request, what is your use case :
  • Sample project : [GitHub Clone URL] docker -v :
Docker version 24.0.6, build ed223bc

lin-mt avatar Nov 24 '23 02:11 lin-mt

@lin-mt : Do you get some error while plugin is building image? Default behavior is to try cleaning up dangling images. Have you specified cleanup configuration option via plugin configuration?

rohanKanojia avatar Nov 25 '23 05:11 rohanKanojia

@lin-mt : Do you get some error while plugin is building image? Default behavior is to try cleaning up dangling images. Have you specified cleanup configuration option via plugin configuration?

            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.43.4</version>
                <configuration>
                    <images>
                        <image>
                            <name>docker-application:${project.version}</name>
                            <build>
                                <dockerFileDir>${project.basedir}</dockerFileDir>
                            </build>
                        </image>
                        <image>
                            <name>docker-application:latest</name>
                            <build>
                                <dockerFileDir>${project.basedir}</dockerFileDir>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>

this is my config. and I run this task: image

lin-mt avatar Nov 27 '23 01:11 lin-mt

This is log.

[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< cn.linmt:application-service >------------------
[INFO] Building application-service 1.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- docker:0.43.4:build (default-cli) @ application-service ---
[INFO] Building tar: C:\Users\linmt\IdeaProjects\application\application-service\target\docker\docker-application\1.0.0\tmp\docker-build.tar
[INFO] DOCKER> [docker-application:1.0.0]: Created docker-build.tar in 2 seconds 
[INFO] DOCKER> [docker-application:1.0.0]: Built image sha256:289c2
[INFO] DOCKER> docker-application:1.0.0: Removed dangling image sha256:d6a3a
[INFO] Building tar: C:\Users\linmt\IdeaProjects\application\application-service\target\docker\docker-application\latest\tmp\docker-build.tar
[INFO] DOCKER> [docker-application:latest]: Created docker-build.tar in 1 second 
[INFO] DOCKER> [docker-application:latest]: Built image sha256:289c2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  28.682 s
[INFO] Finished at: 2023-11-27T09:20:39+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] 
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING] 
[WARNING]  * io.fabric8:docker-maven-plugin:0.43.4
[WARNING] 
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE]
[WARNING] 

Process finished with exit code 0

It doesn't seem to remove dangling image with the latest tag.

lin-mt avatar Nov 27 '23 01:11 lin-mt

Updating the maven version to 3.9.8 solved the issue for us

mydeveloperplanet avatar Jul 08 '24 12:07 mydeveloperplanet