Skip to content

Instantly share code, notes, and snippets.

@spara
Last active May 16, 2016 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spara/721845f732b4ef241536c58dc8020551 to your computer and use it in GitHub Desktop.
Save spara/721845f732b4ef241536c58dc8020551 to your computer and use it in GitHub Desktop.
useful docker commands

Stopping and removing containers and volumes

Note: If you get a "no space left on device error", you may have stopped containers taking up space.

Show all containers, running and stopped

docker ps -a

One liner to stop / remove all of Docker containers:

docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)

Remove images:

images: docker rmi $(docker images -q)

Remove volumes and containers:

docker rm -v $(docker ps -a -q)

To only stop exited containers and delete only non-tagged images.:

docker ps --filter 'status=Exited' -a | xargs docker stop docker images --filter "dangling=true" -q | xargs docker rmi

Remove all containers that aren't currently running:

docker rm $(docker ps -a -q -f "status=exited*")

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