dockerfile-maven
dockerfile-maven copied to clipboard
Add new "rmi" mojo to remove images
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
.
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?
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 :-)
when it will be merged to master?
when it will be merged to master?