Show Menu
Cheatography

Docker Cheat Sheet (DRAFT) by

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

Instal­lation

docker run [image]
Downloads image and starts as container
docker image ls
Lists all local available images
docker ps
Lists all running containers
docker ps -a
Lists all containers
docker search [image]
Search for image in docker hub
docker pull [image]
Download image from hub
docker inspect [conta­iner] | more
Shows container details
docker rm -f [conta­iner]
Removes container
docker rmi [image]
Removes image

docker run

-d
Runs container in background (detached)
--name [conta­ine­r_name]
Runs as contai­ner­_name
docker exec -it [conta­iner] /bin/sh
Executes shell in container
-e "­VIR­TUA­L_H­OST­=ex­amp­le.c­om­"
Enviro­nment variables
--network [netwo­rk_­name]
Starts in UDNetwork
-v [host-­src­:]c­ont­ain­er-­des­t[:­<op­tio­ns>]
Mounts "­hos­t-s­rc" as "­con­tai­ner­-de­st"
-p [host_­por­t]:­[co­nta­ine­r_port]
Maps ports to host machine
mount options: rw, ro, nocopy
 

docker volumes

docker volume ls --filter dangli­ng=true
Lists unused docker volumes
docker volume prune
Removes all unused docker volumes (!)
docker volume create [volum­e_name]
Creates new volume
docker volume inspect [volum­e_name]
Inspects volume content

docker network

docker network inspect [netwo­rk_­name]
Shows network details
docker network create [netwo­rk_­name]
Creates new network
docker network ls
lists all available networks