Skip to content

Instantly share code, notes, and snippets.

@mugifly
Created August 18, 2016 07:17
Show Gist options
  • Select an option

  • Save mugifly/ffd3973d34c4a1b7c303cf024944a6f4 to your computer and use it in GitHub Desktop.

Select an option

Save mugifly/ffd3973d34c4a1b7c303cf024944a6f4 to your computer and use it in GitHub Desktop.

Revisions

  1. mugifly created this gist Aug 18, 2016.
    12 changes: 12 additions & 0 deletions docker-clean.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/sh

    echo -e "-- Removing exited containers --\n"
    docker ps --all --quiet --filter="status=exited" | xargs --no-run-if-empty docker rm --volumes

    echo -e "\n\n-- Removing untagged images --\n"
    docker rmi --force $(docker images | awk '/^<none>/ { print $3 }')

    echo -e "\n\n-- Removing volume directories --\n"
    docker volume rm $(docker volume ls --quiet --filter="dangling=true")

    echo -e "\n\nDone :)"