Skip to content

Instantly share code, notes, and snippets.

@SQiShER
Created December 17, 2015 16:13
Show Gist options
  • Save SQiShER/ace50d1ffaebc714eb5c to your computer and use it in GitHub Desktop.
Save SQiShER/ace50d1ffaebc714eb5c to your computer and use it in GitHub Desktop.
Delete unused Docker images

In theory it shouldn't be a problem to run docker rmi on images that are currently in use, as Docker will simply skip them.

In practice this doesn't seem to be bulletproof. On more than one occasion this caused weird problems, so I prefer to only run rmi for images that I know, are not in use.

Here's the command I use to do so:

docker rmi $(docker inspect -f '{{.Image}}' `docker ps -a -q --no-trunc` | grep -v -f - <(docker images -q --no-trunc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment