Show Menu

Docker basics Cheat Sheet by

Docker
docker

Overview

docker
Run these docker sub-co­mmands to have an overview of the Docker daemon.
ps
List running containers
ps -a
List all containers
images
List all images
version
Display version
info
Various inform­ations on the Daemon

Building an image

docker build DIR
Build an image from the current directory, by default.
Example: docker build -t my-image .
-t
The tag of the built image
 

Running a container

docker run
Run a container from a given image. docker run IMAGE-­NAME
-d
Run in background
-i
Intera­ctive session
-t
TTY
-p H:C
Exposes the port C of the container to the port H of the host
-v H:C
Mount the host path H at the path C in the container
--rm
Remove the container when exited
--name
Give a name to the container

Docker­-Co­mpose

docke­r-c­ompose [command]
Manage the Docker applic­ation stack.
up
Run the stack
-d
Run in the background
kill
Kill all the containers or a specific one if precised
scale
Scale the given container with the given amount of replicas.
docker-compose scale CONTAI­NER­=RE­PLICAS
ps
List running containers of the stack
rm
Remove the containers
build
Force (re)build of the stack's containers
 

Managing a container

docker
Run the following sub-co­mmands followed by the container ID or name.
Example: docker kill nginx
logs
Get the logs of the container
--follow
Follow the logs
rm
Remove the container
-f
Force removal of the container
kill
Kill the container
inspect
Inspect the details of a container

dock-cli

dock-cli [command]
Manage the Docker applic­ation stack.
start
Start the applic­ation stack
ps
List running containers
reset
Reset the given containers
docke­r:d­octor
Run a set of tests about the Docker setup
docke­r:i­nstall
Install Docker and configure it to have direct IP routing and DNS resolution with DnsDock

kubectl

--namespace=NAMESPACE
Set the command's context
config use-co­ntext
Change the current config­uration context.
get OBJECT [name]
Get the given object(s). If name is given only get the object with the given name instead of a list.
OBJECT can be: pod, rc, service, ds, deplo­yment, pvc, pv, ingre­sses, ...
-o yaml
Outputs a YAML instead of printing the details
describe OBJECT NAME
Describe the given object. Will display basics and events.
exec POD COMMAND
Run a given command in a pod.
exec -it POD /bin/bash
-it
Ask for an intera­ctive shell
create -f FILE
Create a resource from the file FILE
delete OBJECT NAME
Delete the object of type OBJECT named NAME
logs POD
Get the logs of the pod named POD
edit OBJECT NAME
Edit the YAML definition of the object

Download the Docker basics Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/sroze_docker-basics.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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

          docker-compose Cheat Sheet
          Docker OSX use Cheat Sheet