Dockerizing things

I’m into docker, going through the tutorial when I ran out of space.
After a scare (system would not boot) I started doing some cleanup.
I installed bleachbit and I’m using that to clean things in an orderly way.
I’ll use ‘package manager’ to git rid of old packages.
And I found something that a docker guy wrote to handle docker stuff:
The gist is here
The text below:
#!/bin/sh                                                                                                                                                      remove_dangling() {
   echo "Removing dangling images ..."
   docker rmi $(docker images -f dangling=true -q)
}
remove_stopped_containers() {
    echo "Removing stopped containers ..."
    docker rm $(docker ps -qa)
}
case $1 in
    images)
        remove_dangling
        ;;
    containers)
        read -p "Are you sure you want to remove all stopped containers?" -n 1 -r
        echo  #                                                                                                                                               
        if [[ $REPLY =~ ^[Yy]$ ]]
        then
            remove_stopped_containers
        fi
        ;;
    *)
        echo "                                                                                                                                                                       
usage: docker-clean containers|images                                                                                                     
    containers - removes all stopped containers it can.                                                                               
    images - removes dangling (un-needed) image layers - images you no longer need                            
"
        ;;
esac

Comments

Popular Posts