Skip to content

Instantly share code, notes, and snippets.

@jottr
Last active August 29, 2015 14:10
Show Gist options
  • Save jottr/5e23fd2a888c4f85bec1 to your computer and use it in GitHub Desktop.
Save jottr/5e23fd2a888c4f85bec1 to your computer and use it in GitHub Desktop.
Keeping a clean docker environment, taken from http://www.carlboettiger.info/2014/08/29/docker-notes

Keeping a clean docker environment run interactive containers with --rm flag to avoid having to remove them later.

Remove all stopped containers:

$ docker rm $(docker ps -a | grep Exited | awk '{print $1}')

Clean up un-tagged docker images:
$ docker rmi $(docker images -q --filter "dangling=true")

Stop and remove all containers (including running containers!)
$ docker rm -f $(docker ps -a -q)

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