Show Menu
Cheatography

These are the docker commands I use daily

Creating and Starting

run
Create and run a container from an image
run --rm
Automa­tically remove the container when it exits
run -d
Run container in background and print container ID
start
Start one or more stopped containers
CTRL+P, CTRL+Q
Detach from container without killing it

compos­e.yaml

version (optional)
services (optional)
volumes
networks

compose services

image
ports
enviro­nment
networks
volumes
 

Monitoring

images
List local images
ps
To list currently running contai­­ners
history
Show the history of an image
inspect
Return low-level inform­ation on Docker objects
attach
Attach local standard input, output, and error streams to a running container
stop
Stop one or more running containers
logs
Fetch the logs of a container
exec
Execute a command in a running container

Compose

up
Create and start containers
up -d
Detached mode: Run containers in the background
stop
Stop services
start
Start services
logs
View output from containers
down
Stop and remove contai­ners, networks
down -v
Remove contai­ners, netwRemove named volumes declared in the "­vol­ume­s" section of the Compose file and anonymous volumes attached to contai­ner­s.orks, volumes
 

Networking

run -p
Publish a contai­ner's port(s) to the host
run --network
Connect a container to a network
network
Manage networks
network create -d
Driver to manage the Network: none, bridge, host, overlay, macvlan

Dockerfile

FROM
Create a new build stage from a base image
RUN
Execute build commands

Build image

build
Build an image from a Dockerfile
build -t
Name and optionally a tag in the name:tag format

Volumes

run -v
Bind mount a volume
volume create
Create a volume
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Android Package Manager (pm) Cheat Sheet
          Basic Cisco IOS Commands Cheat Sheet

          More Cheat Sheets by nirintsoa

          Ruby Array and String Cheat Sheet
          Programming Interview Live Coding Cheat Sheet