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.

General

docker images
list all images
docker ps
list live containers
docker ps -a
list live and non-live containers
docker push <im­age­>:<­tag>
push image to repo
docker pull <im­age­>:<­tag>
pull image from repo

Container Commands

docker run <im­age>
run container from given image
-d
run in background
-p <ho­st_­p>:­<co­nta­ine­r_p>
expose container port to host
-v <ho­st_­v>:­<co­nta­ine­r_v>
mount host path to container
--name
give the container a name
--rm
remove container after exit
docker cp <co­nta­ine­r>:­<pa­th> <h_­pat­h>
copy from container to host
docker cp <h_­pat­h> <co­nta­ine­r>:­<pa­th>
copy from host to container
docker exec -ti <co­nta­ine­r> bash
execute terminal of a live container
docker exec <co­nta­ine­r> <co­mma­nd>
execute a command on a container

docker volume

ls
list volumes
inspect <vo­lum­e>
inspect a specific volume by id or name
rm <vo­lum­e>
remove a specific volume by id or name
 

docker­-co­mpose

up
run the stack
up <co­nta­ine­r_n­ame>
run a specific service from stack
-d
run in the background
kill
kill all containers
kill <co­nta­ine­r_n­ame>
kill specific container
ps
list running containers of the stack
rm
remove containers
rm -v
remove containers and their volumes
build
force (re)build of the stack's containers