Skip to content

Instantly share code, notes, and snippets.

@HelioCampos
Forked from jcmartins/Docker utils
Last active April 5, 2016 13:57
Show Gist options
  • Save HelioCampos/e789edbf2d7a79a17889 to your computer and use it in GitHub Desktop.
Save HelioCampos/e789edbf2d7a79a17889 to your computer and use it in GitHub Desktop.
Cleanup Docker Images
Delete all containers
docker rm $(docker ps -a -q)
Delete all images
docker rmi $(docker images -q)
Removes all containers running under Docker, so use with caution.
docker ps -a | awk '{print $1}' | xargs docker kill
Removing all Containers that are not running:
docker rm $(docker ps --filter "status=exited" -q --no-trunc)
-a is not needed when using --filter status=exited.
-f allows you to filter your list of printed containers (in this case we are filtering to only show exited containers)
-q prints just the container ids (without column headers)
Now this removes all the dangling non intermediate <none> images:
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment