Show Menu
Cheatography

Docker (2) Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Lifecycle

docker create
creates a container but does not start it.
docker rename
allows the container to be renamed.
docker run
creates and starts a container in one operation.
docker rm
deletes a container.
docker update
updates a contai­ner's resource limits.

Starting and Stopping

docker start
starts a container so it is running.
docker stop
stops a running container.
docker restart
stops and starts a container.
docker pause
pauses a running container, "­fre­ezi­ng" it in place.
docker unpause
will unpause a running container.
docker wait
blocks until running container stops.
docker kill
sends a SIGKILL to a running container.
docker attach
will connect to a running container.
If you want to integrate a container with a host process manager, start the daemon with -r=false then use docker start -a.

Info

docker ps
shows running contai­ners.
docker logs
gets logs from container. (You can use a custom log driver, but logs is only available for json-file and journald in 1.10)
docker inspect
looks at all the info on a container (including IP address).
docker events
gets events from container.
docker port
shows public facing port of container.
docker top
shows running processes in container.
docker stats
shows contai­ners' resource usage statis­tics.
docker diff
shows changed files in the contai­ner's FS.
docker ps -a shows running and stopped contai­ners.

docker stats --all shows a running list of contai­ners.

Import / Export

docker cp
copies files or folders between a container and the local filesy­stem..
docker export
turns container filesystem into tarball archive stream to STDOUT.

Executing Commands

docker exec
to execute a command in container.
To enter a running container, attach a new shell process to a running container called foo, use: docker exec -it foo /bin/bash.
 

RUN

Dockerfile reference for the RUN instru­ction

As always, to make your Dockerfile more readable, unders­tan­dable, and mainta­inable, split long or complex RUN statements on multiple lines separated with backsl­ashes.