Skip to content

Instantly share code, notes, and snippets.

@fahimbabarpatel
Last active September 6, 2017 13:23
Show Gist options
  • Save fahimbabarpatel/578f3959bdb6b994a358c04d2a964d8b to your computer and use it in GitHub Desktop.
Save fahimbabarpatel/578f3959bdb6b994a358c04d2a964d8b to your computer and use it in GitHub Desktop.
Docker commands

One liner to stop / remove all of Docker containers:

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

Remove only stopped containers can be listed using:

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

Remove all dangling images

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Remove conatiners of specific image

docker rm $(docker stop $(docker ps -a -q --filter ancestor="image-name" --format="{{.ID}}"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment