Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. # Here’s how I periodically purge my docker host:
  2.  
  3. # Kill running containers:
  4. docker ps -q | xargs docker kill
  5.  
  6. # Delete all containers (and their associated volumes):
  7. docker ps -q -a | xargs docker rm -v
  8.  
  9. # Remove all images:
  10. docker images -q | xargs docker rmi
  11.  
  12. # Notes:
  13. # The “-q” option prints the numeric ids
  14. # The “xargs” command is a handy way to repeatedly run a docker command
  15.  
  16. # Update
  17. # Delete only the containers that are not running. Parse the “ps” output for the “Exited” string:
  18.  
  19. docker ps -a | awk '/Exited/ {print $1}' | xargs docker rm -v
  20. # Not perfect… Don’t give your container the name “Exited” :-)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement