sudo nano /usr/bin/docker_fresh
#!/usr/bin/env bash
#
# Obliterates containers, images, networks, volumes, and cache.
#
[ $(docker ps | wc -l) -ne 1 ] && echo "Stopping containers..." && docker stop $(docker ps | sed -n '1d;p' | awk -F" " '{print $1}')
[ $(docker ps -a | wc -l) -ne 1 ] && echo "Deleting containers..." && docker rm $(docker ps -a | sed -n '1d;p' | awk -F" " '{print $1}')
[ $(docker images | wc -l) -ne 1 ] && echo "Deleting images..." && docker image rm $(docker images | sed -n '1d;p' | awk -F" " '{print $3}')
echo "Pruning networks, volumes, and cache..." && docker system prune -a -f --volumes
echo "Docker is fresh again."
sudo chmod +x /usr/bin/docker_fresh