Dockerfile-maven: Support for Remove Image before build

Created on 4 Jul 2017  路  7Comments  路  Source: spotify/dockerfile-maven

like the docker-maven-plugin, provide a goal like removeImage ?

stale

Most helpful comment

My personal opinion is that things like cleaning up the local environment would be better left to commands like "docker system prune" etc. I don't think it is our intent to make it possible to do everything that you can do with the docker cli possible to do with a Maven goal as well. I'm not sure if other maintainers feel any different though.

All 7 comments

What is the use case for removing an image before building it?

I would to comment: I experience that building several times that I end up having multiple copies locally without a name and tag.

Output from docker images:

REPOSITORY TAG IMAGE ID CREATED SIZE
debian-postgres-awscli-base latest 947cb248393d 7 minutes ago 139MB
debian-postgres-base latest 5f083e409665 8 minutes ago 70.2MB
dc4889b5b1ba About an hour ago 139MB
fe7af7f4e275 About an hour ago 70.2MB

I expect this is @beihaifeiwu's use case. Removing the image before building would clean up the local repository.

My personal opinion is that things like cleaning up the local environment would be better left to commands like "docker system prune" etc. I don't think it is our intent to make it possible to do everything that you can do with the docker cli possible to do with a Maven goal as well. I'm not sure if other maintainers feel any different though.

For me this is about letting the build to clean after itself. Adding the image removal feature to the plugin would allow the clean up to be automated nicely, since the build knows what images it has built.

The alternative is to try and re-consturct the image names and call docker rmi on them, which to me doesn't sound very nice.

I have the problem building SNAPSHOT images. If the image with the same tag (e.g. 1.0.2-SNAPSHOT) is already here and running, then I get two images with the same tag. Second start of the same image uses then old one. The workaround for this is then docker rmi -f 1.0.2-SNAPSHOT. It would be nice to have this possibility in dockerfile-maven plugin configuration.

NOTE: this strange behavior with two different images tagged with same name occurs only when I am using remote docker daemon (DOCKER_HOST=tcp://...). I have done extensive tests with docker cli which behaves same. When I am using DOCKER_HOST=unix:///var/run/docker.sock (e.g. inside container using cli docker build) then everything works fine (old Image gets untagged and the new one will be created and tagged).

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings