-
-
Save HelioCampos/e789edbf2d7a79a17889 to your computer and use it in GitHub Desktop.
Cleanup Docker Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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