Skip to content

Instantly share code, notes, and snippets.

@Komorebi-E
Komorebi-E / clean-docker.sh
Last active June 11, 2019 09:04
Clean up docker containers, images, networks - Stops all containers, force remove containers and their images, prune networks
#!/bin/bash
# Remove any docker containers that are running:
# stop, remove them, their images, volumes and networks.
if $(docker ps -a -q | grep -qE "[a-z0-9]") || $(docker images | grep -qE "[a-z0-9]"); then
if [[ $(docker ps -a -q | head -c1 | wc -c) -ne 0 ]]; then
docker ps -a -q | xargs docker stop
fi
### Keybase proof
I hereby claim:
* I am komorebi-e on github.
* I am adey (https://keybase.io/adey) on keybase.
* I have a public key ASDBJ7_KCK4L88-iVkc9-YiohJOoMvVC9Ru5NFyt1H2n1go
To claim this, I am signing this object: