0% found this document useful (0 votes)
14 views

Docker Basics Cheatsheet

The Docker Cheat Sheet provides essential commands for managing containers, images, and networks in Docker. It includes instructions for running, stopping, and inspecting containers, as well as creating and managing Dockerfiles and Docker Compose. Additionally, it outlines commands for handling volumes and interacting with Docker registries.

Uploaded by

Bart Mania
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Docker Basics Cheatsheet

The Docker Cheat Sheet provides essential commands for managing containers, images, and networks in Docker. It includes instructions for running, stopping, and inspecting containers, as well as creating and managing Dockerfiles and Docker Compose. Additionally, it outlines commands for handling volumes and interacting with Docker registries.

Uploaded by

Bart Mania
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Docker Cheat Sheet

by notapatch via cheatography.com/69520/cs/17564/

Container Running Container Management Commands Management

Run a new container List containers What version

docker container run [options] IMAGE[​:TAG] docker container ls docker version


[COMMAND]
docker ps old command Config​uration values for the docker engine
Options
Create a container docker info
--rm remove container
docker container create [OPTIONS] List of all commands
on exit
IMAGE docker
--name add container ID
Remove a container
-e set enviro​nment
Networks
variable docker container rm

-p publish container -f force removal of running container List network


ports to host docker network ls
Remove all stopped containers
--network connect container Inspect network
docker container prune
to network
docker network inspect
--net-alias network scoped List processes in specific container

alias for the docker container top [conta​iner] Create a network

container docker network create [network]


Show logs on specific container
-d container in Attach a network to container
docker container logs [conta​iner]
background /
docker network connect [network]
detached List docker container commands
[conta​iner]
-it run intera​ctively docker container
Detach a network from container
-v=[h​ost​- Volume
sr​c:]​con​tai​ner​- Container commands docker network disconnect [network]
[conta​iner]
de​st[​:<o​pti​ons​>] start a new container intera​ctively

-v $(pwd)​:/app map the pwd into docker container run -it


Images
the '/app' folder
Run additional process in running container
Start an existing Container List images
docker container exec CONTAINER
docker container start [conta​iner] docker images [OPTIONS]
[CMD]
-a attach Re-tag an image
docker container exec -it
docker image tag SOURCE_IMAGE[:tag]
-i intera​ctive my_alpine ping my_ubuntu
TARGET_IMAGE[:tag]
Stop a running container docker container run --rm --net
Log in to registry (the Docker Hub by default)
docker container stop [conta​iner] bcs alpine nslookup search
docker login
Kill a running container List of ports forwarding traffic from host to
container Push an image to the registry
docker container kill [conta​iner]
docker container port [conta​iner] docker push [options] NAME[:​TAG]

Display detailed container inform​ation Pull an image

docker container inspect docker pull [options] NAME[:​TAG]

Build an image from a Dockerfile

docker image build [OPTIONS] PATH

-t tag

By notapatch Not published yet. Sponsored by CrosswordCheats.com


cheatography.com/notapatch/ Last updated 25th October, 2018. Learn to solve cryptic crosswords!
Page 1 of 2. http://crosswordcheats.com
Docker Cheat Sheet
by notapatch via cheatography.com/69520/cs/17564/

Docker File - image recipies

Set the base image for further instru​ctions

FROM <im​age​>[:​<ta​g>]

Set enviro​nment variables

ENV <ke​y>=​<va​lue​>

Set instru​ction to execute

RUN <co​mma​nd> [&​& <co​mma​nd>]

Set the ports that the container listens on

EXPOSE <po​rt> [<p​ort​>/<​pro​toc​ol>...]

Default command for executing container

CMD ["ex​ecu​tab​le", "​par​am1​", "​par​am2​"]

Working directory changed for later instru​ctions

WORKDIR /path/​to/​wor​kdir

Copy files

COPY [--cho​wn=​<us​er>​:<g​rou​p>] <sr​c>... <de​st>

Docker Compose

Start system

docke​r-c​ompose up

--build - rebuild container

-d detach​/launch in background

Stop and Remove system

docke​r-c​ompose down

List containers

docke​r-c​ompose ps

Docker Volume

Where does the container keep the volume?

docker container inspect [options] CONTAINER

Detailed inform​ation on one or more volume

docker volume inspect [OPTIONS] VOLUME

List volumes

docker volume ls [OPTIONS]

Remove all unused local volumes

docker volume prune

By notapatch Not published yet. Sponsored by CrosswordCheats.com


cheatography.com/notapatch/ Last updated 25th October, 2018. Learn to solve cryptic crosswords!
Page 2 of 2. http://crosswordcheats.com

You might also like