Skip to content

Instantly share code, notes, and snippets.

@felipe3dfx
Last active February 15, 2018 20:27
Show Gist options
  • Save felipe3dfx/18346f57d0a712515e9b95cb1f26d0f1 to your computer and use it in GitHub Desktop.
Save felipe3dfx/18346f57d0a712515e9b95cb1f26d0f1 to your computer and use it in GitHub Desktop.
How to remove unused Docker containers and images
  1. Removing all images is

     #!/bin/bash
     $ docker ps -q -a | xargs docker rm -f
    
  2. Removing all containers

     #!/bin/bash
     # Delete all dangling (unused) images
     docker rmi $( docker images -f dangling=true -q )
    
  3. Remove volumes

     #!/bin/bash
     docker volume rm $(docker volume ls -qf dangling=true)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment