Skip to content

Instantly share code, notes, and snippets.

@sibosend
Last active July 16, 2019 06:04
Show Gist options
  • Save sibosend/cd1daf763839494214c3a67eb14b43c0 to your computer and use it in GitHub Desktop.
Save sibosend/cd1daf763839494214c3a67eb14b43c0 to your computer and use it in GitHub Desktop.
Docker Cheat Sheet

Table of Contents

  1. Purging All
  2. Images
  3. Containers
  4. Volumes

Purging

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

clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):

$ docker system prune

Removing Docker Images

Remove one or more specific images

List

$ docker images -a

Remove

$ docker image rm Image Image

Remove all images

$ docker rmi $(docker images -a -q)

Removing Containers

Remove one or more specific containers

List

$ docker ps -a

Remove

$ docker rm ID_or_Name ID_or_Name

Remove all exited containers

List

$ docker ps -a -f status=exited

Remove

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

SSH into a Container

$ docker exec -it <container name> /bin/bash

Get Ip Address

$ docker inspect <containerNameOrId> | grep '"IPAddress"' 

Removing Volumes

Remove one or more specific volumes - Docker 1.9 and later

List

$ docker volume ls

Remove

$ docker volume rm volume_name volume_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment