Show Menu

Docker cheat Cheat Sheet (DRAFT) by

Basic Docker commands

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Docker image manipu­lations

Run detached container - Debian OS
docker -dit debian
Stop container
docker stop [CONTAINER CID]
Show docker images
docker images
Show docker image info in YAML
docker inspect [CONTAINER CID]
Get docker image
docker pull [IMAGE NAME]
Get how image was constr­ucted
docker history [IMAGE NAME]
Show full image hash
docker images --no-trunc
Create image tag
docker tag SOURCE­[:TAG] TARGET­[:TAG]
pause a container
docker pause [CONTAINER CID]
unpause a paused container
docker unpause [CONTAINER CID]
send a kill signal to a running container
docker kill [CONTAINER CID]
block until a running container stops
docker wait [CONTAINER CID]
connect to a running container
docker attach [CONTAINER CID]
rename an existing container
docker rename contai­ner­-name new-co­nta­ine­r-name
rename an existing container
docker run --rm image-name

Dockerfile Manipu­lations

Simple Dockerfile example
FROM debian­:stable LABEL mainta­ine­r="E­NTE­R_Y­OUR­_NA­ME_­HER­E" RUN apt update && apt install -y nano && apt clean CMD [ "­/bi­n/b­ash­" ]
Simple Dockerfile example

Docker Inform­ation Commands

Docker Inform­ation Commands
docker info
To list only running containers
docker ps
To list all containers
docker ps -a
print the object inform­ation about a container
docker logs contai­ner-id
print all running processes in a container
docker top contai­ner-id
print the live resource usage of any container
docker stats cntain­er-id
print the changes on files and direct­ories in a filesystem
docker diff contai­ner-id

Docker Volume commands

create a new Docker volume
docker volume create volume­-name
list all Docker volumes
docker volume list
print more inform­ation about a Docker volume
docker volume inspect volume­-name
remove a Docker volume from your system
docker volume rm volume­-name

Docker networking

list all the networks
list all the networks
print inform­ation about one or more networks
docker network inspect networ­k-name
connect a container to a network
docker network connect networ­k-name contai­ner­-name
disconnect a container from a network
docker network disconnect networ­k-name contai­ner­-name
remove one or more networks
docker network rm networ­k-name