Skip to content

Instantly share code, notes, and snippets.

@rubystream
Created September 16, 2018 10:52
Show Gist options
  • Save rubystream/e1ca19cec0b1bfa3e835379698b0eef5 to your computer and use it in GitHub Desktop.
Save rubystream/e1ca19cec0b1bfa3e835379698b0eef5 to your computer and use it in GitHub Desktop.
A Docker Cheat Sheet

A Docker Cheat Sheet

Purging All Unused or Dangling Images, Containers, Volumes, and Networks

docker system prune

To remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command:

docker system prune -a

Removing Docker Images

Use the docker images command with the -a flag to locate the ID of the images you want to remove.

# list images
docker images -a

# remove 
docker rmi <Image ID or name> 

Remove dangling images

# list dangling images
docker images -f dangling=true

# remove
docker images purge

Remove all images

docker rmi $(docker images -a -q)

Removing Containers

# list
docker ps -a

# remove
docker rm <contaner ID or name>

Remove all exited containers

# list
docker ps -a -f status=exited

# remove
docker rm $(docker ps -a -f status=exited -q)

# remove all containers
docker rm $(docker ps -a -q)

Removing Volumes

# list 
docker volume ls

# remove
docker volume rm <volume name>

Remove dangling volumes

# list
docker volume ls -f dangling=true

# remove
docker volume prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment