Show Menu
Cheatography

Docker basics Cheat Sheet by

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

docker­-co­mpose [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­-co­mpose 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
docker­:doctor
Run a set of tests about the Docker setup
docker­:in­stall
Install Docker and configure it to have direct IP routing and DNS resolution with DnsDock

kubectl

--name­spa­ce=­NAM­ESPACE
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
,
deployment
,
pvc
,
pv
,
ingresses
, ...
-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
 

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 Cheat Sheet