The Ultimate Docker Cheat Sheet - Dockerlabs
The Ultimate Docker Cheat Sheet - Dockerlabs
View on GitHub Join Slack Docker Cheatsheet Docker Compose Cheatsheet Follow us on Twitter
A cheatsheet is a concise summary of important information that is meant to be used as a quick reference.
Cheatsheets are often used in the form of a list or a table, and they typically cover a specific topic or subject
area. In the context of Docker, a Docker cheatsheet is a summary of commonly used Docker commands and
their options, as well as other useful information related to Docker.
Cheatsheets can be particularly helpful when learning a new tool or technology, as they provide a convenient
way to quickly look up and remind oneself of key concepts and commands. They can also be useful for
experienced users who need to recall a specific command or option but may not remember all the details.
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 1/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
Table of Contents
Categories
🐳 Basic Docker CLIs
🧰 Container Management CLIs
🧑💻 Inspecting the Container
🧑💻 Interacting with Container
🫙 Image Management Commands
🧪 Image Transfer Commands
🏗️Builder Main Commands
⚙️The Docker CLI
🧑🤝🧑 Contributors
💬 Support and Community
👉 References
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 2/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 3/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 4/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 5/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 6/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 7/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
Manage images
docker build
docker run
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 8/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
Manage containers
docker create
Example
docker exec
Example
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 9/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
docker start
Start/stop a container .
docker ps
$ docker ps
$ docker ps -a
$ docker kill $ID
Images
docker images
$ docker images
REPOSITORY TAG ID
ubuntu 12.10 b750fe78269d
me/myapp latest 7b2431a8d968
Manages image s.
docker rmi
Deletes image s.
Also see
Getting Started (docker.io)
Dockerfile
Inheritance
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 10/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
FROM ruby:2.2.2
Variables
Initialization
WORKDIR /myapp
VOLUME ["/data"]
# Specification for mount point
Onbuild
Commands
EXPOSE 5900
CMD ["bundle", "exec", "rails", "server"]
Entrypoint
This will use shell processing to substitute shell variables, and will ignore any CMD or docker run command line
arguments.
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 11/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
Metadata
LABEL version="1.0"
See also
https://docs.docker.com/engine/reference/builder/
docker-compose
Basic example
# docker-compose.yml
version: '2'
services:
web:
build: .
# build from Dockerfile
context: ./Path
dockerfile: Dockerfile
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: redis
Commands
docker-compose start
docker-compose stop
docker-compose pause
docker-compose unpause
docker-compose ps
docker-compose up
docker-compose down
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 12/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
Reference
Building
web:
# build from Dockerfile
build: .
Ports
ports:
- "3000"
- "8000:80" # guest:host
Commands
# command to execute
command: bundle exec thin -p 3000
command: [bundle, exec, thin, -p, 3000]
Environment variables
# environment vars
environment:
RACK_ENV: development
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 13/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
environment:
- RACK_ENV=development
Dependencies
Other options
volumes:
- /var/lib/mysql
- ./_data:/var/lib/mysql
Advanced features
Labels
services:
web:
labels:
com.example.description: "Accounting web app"
DNS servers
services:
web:
dns: 8.8.8.8
dns:
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 14/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
- 8.8.8.8
- 8.8.4.4
Devices
services:
web:
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
External links
services:
web:
external_links:
- redis_1
- project_db_1:mysql
Hosts
services:
web:
extra_hosts:
- "somehost:192.168.1.100"
sevices
To view list of all the services runnning in swarm
docker service ls
clean up
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 15/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
To leave swarm
Contributors
Sangam biradar - Docker Community Leader
Ajeet Singh Raina - Docker Captain, Collabnix
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 16/17
31.03.2023 18:16 The Ultimate Docker Cheat Sheet | dockerlabs
General
MEMBERS ONLINE
! Mario
24/7 🔊
2saif4u
alentino Hsiao Mount & Blade II: Bannerlord
ancieque
AndréCosolin
AnnaH
AprilWar
Autumn Heart
Ballin't
bjp
breadNbutter
Carpincho
Ch AI
Hangout with people who get it Join Discord
dev.to
Guide how to run and use IRIS for Health docker image in GCloud
dockerlabs is maintained by collabnix.
This page was generated by GitHub Pages.
0.67g of CO2/view Website Carbon
Cleaner than 37% of pages tested
https://dockerlabs.collabnix.com/docker/cheatsheet/#container-management-clis 17/17