Skip to content

Instantly share code, notes, and snippets.

@Joshfindit
Created August 22, 2019 15:28
Show Gist options
  • Save Joshfindit/24d41b54ec6529c71f78bb0effc71246 to your computer and use it in GitHub Desktop.
Save Joshfindit/24d41b54ec6529c71f78bb0effc71246 to your computer and use it in GitHub Desktop.
#!/bin/sh
#Exit `docker-compose run` containers
docker rm $(docker ps -a -f "name=_run_" -q)
#Make sure that exited containers are deleted.
docker rm -v $(docker ps -a -q -f status=exited)
#Remove unwanted ‘dangling’ images
docker rmi $(docker images -f "dangling=true" -q)
#Remove unused networks
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
#Delete unwanted volumes (vfs)
docker volume rm $(docker volume ls -qf dangling=true)
## Extra tool as of docker 1.7.something
# docker system prune -a ## Be aware, this will delete images that currently-running containers are based on (ruby:latest, for example)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment