Skip to content

Instantly share code, notes, and snippets.

@kamilziajka
Last active April 25, 2018 11:38
Show Gist options
  • Save kamilziajka/e90e5dc6e3e2af254eeddd5407323295 to your computer and use it in GitHub Desktop.
Save kamilziajka/e90e5dc6e3e2af254eeddd5407323295 to your computer and use it in GitHub Desktop.
docker remove
# Remove all stopped containers
docker rm $(docker ps -a | grep "Exited" | cut -d " " -f1)
# Remove all images
docker rmi $(docker images | tail -n +2 | awk '{ print $3; }')
# Stop all containers except docker-registry
docker stop $(docker ps -a | grep -v "docker-registry" | tail -n +2 | cut -d " " -f1)
# Remove all containers except docker-registry
docker rm $(docker ps -a | grep -v "docker-registry" | tail -n +2 | cut -d " " -f1)
# Remove all images except registry
docker rmi $(docker images -a | grep -v "registry" | tail -n +2 | tr -s ' ' | cut -d " " -f3)
# Remove all containers
docker rm $(docker ps -a -q)
# 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