Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. log() {
  4. logger -s -t $(basename $0) $1
  5. }
  6.  
  7. log "Started"
  8.  
  9. containers=$(docker ps -a -q)
  10. if [ -n "${containers}" ]; then
  11. log "Cleanup stopped container id(s): ${containers}"
  12. docker rm $containers
  13. fi
  14.  
  15. images=$(docker images -q --filter "dangling=true")
  16. if [ -n "${images}" ]; then
  17. log "Cleanup dangling image id(s): ${images}"
  18. docker rmi $images
  19. fi
  20.  
  21. volumes=$(docker volume ls -q --filter "dangling=true")
  22. if [ -n "${volumes}" ]; then
  23. log "Cleanup dangling volume id(s): ${volume}"
  24. docker volume rm $volumes
  25. fi
  26.  
  27. log "Done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement