dockerfile-maven icon indicating copy to clipboard operation
dockerfile-maven copied to clipboard

Add new "rmi" mojo to remove images

Open cnaj opened this issue 7 years ago • 4 comments

I'm happily using this great plugin in a CI environment, however I have to regularly clean the build host from stale images. This pull request adds a rmi goal that behaves like docker rmi and binds to the pre-clean phase by default.

Additionally, two integration tests make sure the goal can be called, however, no automatic verification if the image was removed is performed. Let me know if I should try to add such a test, which would probably involve calling docker-client classes from verify.groovy.

cnaj avatar Feb 02 '18 16:02 cnaj

Thanks for the contribution! I have not had a chance to take a look at the code yet, but can I ask why not simply cron or regular run something like docker system prune on the build host to tackle the same goal?

mattnworb avatar Feb 02 '18 17:02 mattnworb

We have some projects that depend on other projects’ images as base image. For this, we need an image name in the Dockerfile, so we tag the base image. Once all the images are built and deployed, we could untag and delete the images.

Since we do this for every branch in our CI system, our build host fills up pretty fast. For now, a cron job can clean up the unreferenced images, identify deleted branches and remove those images too, but I feel it’s more straight forward to just delete the images right after the build. If I’ve missed a better approach, I’d be happy to hear it :-)

cnaj avatar Feb 02 '18 18:02 cnaj

when it will be merged to master?

danielvinitski avatar Dec 13 '18 12:12 danielvinitski

when it will be merged to master?

pytomtoto avatar Jun 01 '20 10:06 pytomtoto