Skip to content

Instantly share code, notes, and snippets.

@SkypLabs
Last active December 5, 2018 23:40
Show Gist options
  • Save SkypLabs/56192dfd2750761c4520765ab051398e to your computer and use it in GitHub Desktop.
Save SkypLabs/56192dfd2750761c4520765ab051398e to your computer and use it in GitHub Desktop.
Scripts for removing untagged Docker images and exited Docker containers
#!/usr/bin/env bash
docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm
#!/usr/bin/env bash
docker images | grep '<none>' | awk '{print $3}' | xargs docker rmi
@SkypLabs
Copy link
Author

SkypLabs commented Dec 5, 2018

These two scripts can now be replaced with docker container prune and docker image prune. See https://docs.docker.com/config/pruning/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment