Docker is a great tool, but it can sometimes consume a lot of disk space. docker-clean is a simple bash script you can use to remove all docker images and containers with one command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ git clone https://github.com/zzrotdesign/docker-clean $ cd docker-clean $ ./docker-clean --help Options: -h or --help Opens this help menu -v or --version Prints the current docker-clean version -a or --all Stops and removes all Containers, Images, and Restarts docker -c or --containers Stops and removes Stopped and Running Containers -i or --images Stops and removes all Containers and Images -net or --networks Removes all empty Networks -s or --stop Stops all running Containers --dry-run Adding this additional flag at the end will list items to be removed without running the remove or stop commands -l or --log Adding this as an additional flag will list all image, volume, and container deleting output |
To stop and remove all Docker containers:
1 |
$ ./docker-clean --containers |
To remove all Docker images:
1 |
$ ./docker-clean --images |