gesellix / gradle-docker-plugin

Gradle Docker plugin
MIT License
80 stars 17 forks source link

Dispose Task should fail silently if Image is still in use #268

Closed sgrell closed 1 year ago

sgrell commented 1 year ago

We currently have the problem that we are using the same image in multiple tasks that run in parallel. The container names are unique but they are using the same image. So when the dispose task is executed docker rm is successful but docker rmi fails because the image is still in use. We get an exception with 409 Conflict.

The problem is line 76 in DockerDisposeContainerTask

It is possible to set rmiParentImage to false, however that would mean, that we never cleanup the images, which is not our preferred solution.

Is it possible to add an option to ignore errors or at least these Conflict-errors?

gesellix commented 1 year ago

Sure, I guess it would be safe to ignore and log errors similar to the example at DockerNetworkRmTask.

Would you like to give it a try yourself and submit a pull request?

gesellix commented 1 year ago

Released with https://github.com/gesellix/gradle-docker-plugin/releases/tag/v2022-12-06T08-00-00 :)

sgrell commented 1 year ago

thank you so much, I was just about to get started with it, when I saw that you already fixed it 😄

gesellix commented 1 year ago

Yeah, couldn't keep my hands off it :) If anything is still missing, just leave a note!

sgrell commented 1 year ago

works like a charm :)