Skip to content

Instantly share code, notes, and snippets.

@hatemzidi
Created May 3, 2019 20:43
Show Gist options
  • Save hatemzidi/93e31fbf827c326071810ca1f5ee21e2 to your computer and use it in GitHub Desktop.
Save hatemzidi/93e31fbf827c326071810ca1f5ee21e2 to your computer and use it in GitHub Desktop.
# Remove all stopped containers
# Remove all volumes not used by at least one container
# Remove all networks not used by at least one container
# Remove all dangling images
# https://docs.docker.com/engine/reference/commandline/system_prune/#usage
docker system prune
# Remove leftover containers
docker ps -a -f status=exited -q | xargs -r docker rm
# Remove leftover images
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi
# Remove dangling volumes
docker volume ls -qf dangling=true | xargs -r docker volume rm
#List all containers (only IDs)
docker ps -aq
#Stop all running containers
docker stop $(docker ps -aq)
#Remove all containers
docker rm $(docker ps -aq)
#Remove all images
docker rmi $(docker images -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment