Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

docker rmi the_image

Remove all images

docker rmi $(docker images -qf "dangling=true")

Kill containers and remove them:

docker rm $(docker kill $(docker ps -aq))

Note: Replace kill with stop for graceful shutdown

Remove all images except "my-image"

docker rmi $(docker images | grep -v 'ubuntu\|my-image' | awk {'print $3'})

Or (without awk)

docker rmi $(docker images --quiet | grep -v $(docker images --quiet ubuntu:my-image))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.