Skip to content

Instantly share code, notes, and snippets.

@dcchambers
Forked from n3r0-ch/docker-nuke
Last active December 6, 2019 19:58
Show Gist options
  • Select an option

  • Save dcchambers/0b3d0f927f27bf8339e3367b8b734dae to your computer and use it in GitHub Desktop.

Select an option

Save dcchambers/0b3d0f927f27bf8339e3367b8b734dae to your computer and use it in GitHub Desktop.

Revisions

  1. dcchambers revised this gist Dec 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-nuke-safely
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ if [ $UID != 0 ]; then
    exit 1
    fi

    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and-nicely-spritz-up. Be carefully!"
    echo "docker-nuke-safely exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and-nicely-spritz-up. Be careful!"
    echo
    read -p "Nuke now? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
  2. dcchambers revised this gist Nov 26, 2019. No changes.
  3. dcchambers revised this gist Jul 15, 2019. No changes.
  4. dcchambers revised this gist Jun 26, 2019. No changes.
  5. dcchambers revised this gist Apr 3, 2019. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions docker-nuke-safely
    Original file line number Diff line number Diff line change
    @@ -18,20 +18,23 @@ then
    then
    echo "Stoping all containers"
    docker stop $(docker ps -a -q)
    fi

    echo
    read -p "Would you like to delete all containers? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Deleting all containers"
    docker rm $(docker ps -a -q)
    fi

    echo
    read -p "Would you like to delete all images? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Deleting all images"
    docker rmi $(docker images -q)
    fi

    echo
    read -p "Would you like to delete all volumes? [y/N] " -n 1 -r
    @@ -40,6 +43,7 @@ then
    echo "Deleting all volumes"
    rm -rf /var/lib/docker/volumes/*
    rm -rf /var/lib/docker/vfs/dir/*
    fi

    echo
    echo
  6. dcchambers revised this gist Apr 3, 2019. 2 changed files with 50 additions and 38 deletions.
    38 changes: 0 additions & 38 deletions docker-nuke
    Original file line number Diff line number Diff line change
    @@ -1,38 +0,0 @@
    #!/bin/bash

    #Check if user is root
    if [ $UID != 0 ]; then
    echo "You need to be root to use this script."
    exit 1
    fi

    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and-nicely-spritz-up. Be carefully!"
    echo
    read -p "Nuke now? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then

    echo
    echo "Stop all containers"
    docker stop $(docker ps -a -q)

    echo
    echo "Delete all containers"
    docker rm $(docker ps -a -q)

    echo
    echo "Delete all images"
    docker rmi $(docker images -q)

    echo
    echo "Delete all volumes"
    rm -rf /var/lib/docker/volumes/*
    rm -rf /var/lib/docker/vfs/dir/*

    echo
    echo
    echo "Finished nuking"

    else
    echo "Cancelled"
    fi
    50 changes: 50 additions & 0 deletions docker-nuke-safely
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    #!/bin/bash

    #Check if user is root
    if [ $UID != 0 ]; then
    echo "You need to be root to use this script."
    exit 1
    fi

    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and-nicely-spritz-up. Be carefully!"
    echo
    read -p "Nuke now? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then

    echo
    read -p "Would you like to stop all containers? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Stoping all containers"
    docker stop $(docker ps -a -q)

    echo
    read -p "Would you like to delete all containers? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Deleting all containers"
    docker rm $(docker ps -a -q)

    echo
    read -p "Would you like to delete all images? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Deleting all images"
    docker rmi $(docker images -q)

    echo
    read -p "Would you like to delete all volumes? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
    echo "Deleting all volumes"
    rm -rf /var/lib/docker/volumes/*
    rm -rf /var/lib/docker/vfs/dir/*

    echo
    echo
    echo "Finished nuking"

    else
    echo "Cancelled"
    fi
  7. Felix Imobersteg revised this gist Jul 31, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-nuke
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ if [ $UID != 0 ]; then
    exit 1
    fi

    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and_nicely-spritz-up. Be carefully!"
    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and-nicely-spritz-up. Be carefully!"
    echo
    read -p "Nuke now? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
  8. Felix Imobersteg revised this gist Jul 31, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-nuke
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]
    then

    echo
    echo "Stop all containers"
    echo "Stop all containers"
    docker stop $(docker ps -a -q)

    echo
  9. Felix Imobersteg revised this gist Jul 31, 2015. No changes.
  10. Felix Imobersteg revised this gist Jul 31, 2015. No changes.
  11. Felix Imobersteg revised this gist Jul 31, 2015. No changes.
  12. Felix Imobersteg created this gist Jul 31, 2015.
    38 changes: 38 additions & 0 deletions docker-nuke
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/bash

    #Check if user is root
    if [ $UID != 0 ]; then
    echo "You need to be root to use this script."
    exit 1
    fi

    echo "docker-nuke exists to do one thing; clean up your Docker environment. It's not called docker-carefully-and_nicely-spritz-up. Be carefully!"
    echo
    read -p "Nuke now? [y/N] " -n 1 -r
    if [[ $REPLY =~ ^[Yy]$ ]]
    then

    echo
    echo "Stop all containers"
    docker stop $(docker ps -a -q)

    echo
    echo "Delete all containers"
    docker rm $(docker ps -a -q)

    echo
    echo "Delete all images"
    docker rmi $(docker images -q)

    echo
    echo "Delete all volumes"
    rm -rf /var/lib/docker/volumes/*
    rm -rf /var/lib/docker/vfs/dir/*

    echo
    echo
    echo "Finished nuking"

    else
    echo "Cancelled"
    fi