Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Here’s how I periodically purge my docker host:
- # Kill running containers:
- docker ps -q | xargs docker kill
- # Delete all containers (and their associated volumes):
- docker ps -q -a | xargs docker rm -v
- # Remove all images:
- docker images -q | xargs docker rmi
- # Notes:
- # The “-q” option prints the numeric ids
- # The “xargs” command is a handy way to repeatedly run a docker command
- # Update
- # Delete only the containers that are not running. Parse the “ps” output for the “Exited” string:
- docker ps -a | awk '/Exited/ {print $1}' | xargs docker rm -v
- # Not perfect… Don’t give your container the name “Exited” :-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement