Stale images on running integration tests

I noticed that I have these images from different branches on which I ran the integration-all-local tests, they currently occupy ~20GB of my disk space!

Is there some way to automatically delete these?
I would like to bulk delete these images from all the branches apart from the one I am currently on.

I think using DEBUG=True while running these to preserve the containers is what caused this, though this is just a wild guess.

I’d be happy to write a quick script that does this bulk delete heuristically if a solution doesn’t exist already.

I would just recommend you run a docker image prune -a from time to time. Scrips are welcome, but because the built-in solution is so available, we have found no need to invest time in a custom script.

1 Like

Thanks for the suggestion, but that doesn’t help in my case as I have some images that are used to spin some containers occasionally and rebuilding them would be quite time consuming.
A more targeted way would be quite convenient.

Here is a barebones command that did the job

docker images | grep medicmobile\/cht | grep -v $CURRENT_BRANCH | awk '{print $3}' | xargs -n1 docker rmi
1 Like