Skip to content

Instantly share code, notes, and snippets.

@bdw
Created November 24, 2014 16:09
Show Gist options
  • Save bdw/eb22c70c797d124493a9 to your computer and use it in GitHub Desktop.
Save bdw/eb22c70c797d124493a9 to your computer and use it in GitHub Desktop.
docker remove images and containers
#!/bin/bash
for id in `docker ps -a | cut -c 1-20 | grep -v 'CONTAINER ID'`; do docker rm -f $id; done
if [ "$1" = "-a" ]; then
for id in `docker images | cut -c 41-60 | grep -v 'IMAGE ID'`; do docker rmi -f $id; done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment