Style chooser: Modern, Modern B&W, Modern Colored, Classic, High contrast or Printing
[Hint: Use styles Modern B&W or Printing to print. If you get problems, try printing the PDF versions instead]

Contents

Front Matter


Client version 0.7.1. Server version 0.7.1. (What's new?)
Please report inaccuracies, oversights, and bugs to the GitHub merriam/quick_reference repository
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
This is a work in progress, last updated in 12/2013.
Webpage design based on Richard Gruet's Python Quick Reference.

Useful Links

Docker Commands

Organized by type
Command Meaning Notes
File Systems
 
 
import - | url [REPOSITORY[:TAG]] Import tar file of filesystem into new image. Source can be - for stdin, like docker import - < a6ef_files.tar. Alternately, source can be an http or https URL. Also, the optional REPOSITORY or REPOSITORY:TAG will docker tag the new image, like docker import server.com/files.tar charlesmerriam/dwarf:in_progress
export CONTAINER Export container filesystem as tar file to stdout. Use like docker export a6e5 > a6e5_files.tar (2)
load SOURCE Load an image from a tar archive
save IMAGE Save an image to a tar archive streamed to stdout. Use like docker save e71d > e71d.tar
diff CONTAINER List differences between the filesytem of the container and the filesystem of the image in which it ran. Output lines have a code letter for Changed, Deleted, or Added followed by the file or directory name. Run like docker diff a6e5. (1)
insert IMAGE URL PATH Insert a file from URL into the IMAGE at PATH, creating a new image. Returns the new image ID. It also creates a new container as a side effect.
cp CONTAINER:path path Recursively copy a file or directory out of a container filesystem to the local (host) filesystem. So, docker cp a6e5:/var/log . would copy the directory tree from the container into a new subdirectory ./log, while docker cp a6e5:var/log/dpkg.log dpkg copy a single file from the container to a local existing directory dpkg/dpkg.log. (2)
Docker System Information
 
 
events [-since="timestamp"] Get real time events from the server, optionally including previous events from the current docker deaemon like docker events -since="2013-01-01 04:48:23". Quick with Ctrl-C
info Display system wide information including the number of containers and images.
version Display docker version information including the golang version and git branch of both the client and server.
Container and Image Status
 
 
history [-q][-notrunc] IMAGE Show the history of an image, detailing which images and commands were used in its creation. Use -q to show only the IDs and -notrunc to show full width IDs and commands
inspect [-format="go-template"] containers_or_images Return JSON dump on one or more containers or images. This dump containsall metadata and settings.
images [-notrunc] [-q]
   [-a|-tree|-viz|IMAGE_REGEX]
List images on your local system. -q lists IDs only while -notrunc prints long IDs. With no other arguments,the command prints all images and -a will also list intermediate build images.-tree and -viz print a tree of image ancestory as text or graphviz format. Finally, providing image name or regex lists matching images, likedocker images "u*". (3)(4)
logs [-f] container Fetch transcript of stdout and stderr of container, outputing to both stdout and stderr, like docker logs ae4d > last.stdout.txt 2> last.stderr.txt. Use -f to output transcript and then follow continuing output of a running container.
top CONTAINER [-ps_options] Lists the running processes of a container, like the Unix top command. The ps_options, which are listed after the container_id, can be -notrunc or any of the many ps flags. You can see a list of options by using a valid container_id, like docker top 5e34 -?.
ps [-q] [-notrunc]
port CONTAINER PRIVATE_PORT Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
Running Images
 
 
run image [Command] Run a command in a new container. Lots and lots of options.
start [-a] [-i] Restart a stopped container.
stop [-t=seconds] container_list Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
restart [t=seconds Restart, meaning stop and then start, a running container. -t is the grace period in seconds to allow container to finish.
wait container_list Block until containers stop, printing exit code of each container as it finishes.
More images
 
 
commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] Create a new image from a container's changes
tag Tag an image into a repository
rmi Remove one or more images.
Containers
 
 
attach [-nostdin] [-sig-proxy] Attach to a running container
build [-q] [-no-cache] [-rm] [-t=new_name_and_tag] Build a new container image from the source code at PATH.
kill container_list Kill a running container (send SIGKILL).
rm [-link] [-v] container-list Remove one or more containers.
Working with repositories
 
 
login [-e=email] [-p=password] [-u=username] [ServerURL*] Login to a repository, or the Public Docker Index by default. Also used to create an account, which is followed up with a confirmation email. Login is required for docker push (5)
push image-set Push an image or image set (also called a repository) to the registry, like push charlesmerriam/ping2:latest. Prompts for login information unless logged in. (7)
pull [-t="tag_name"] IMAGE_SET Pull an image set (also called a repository) from the registry. Use -t to pullonly one tagged image from the set, like docker pull -t="latest" charlesmerriam/ping. (7)
search [-notrunc] [-stars=mininum_stars] [-trusted] TERM Search for images in the Public Docker Index with TERM matching in the name or description of the image. You can filter by mininum_stars or select only trusted repositories, like docker search -stars=2 -trusted git. Use -notrunc to see the full descriptions. (6)
The Command Line Documentation may have additional examples.
  • (1) The docker diff command lists aufs internal files. These files are in the root directory and start with .wh..wh..
  • (2) Use docker export to copy an entire filesystem; current limitations return Killed otherwise.
  • (3) Current limitations cause docker image to ignore the *IMAGE* and -q flags when used with -tree or -viz.
  • (4) You can display graphviz format at http://graphviz-dev.appspot.com or run locally like docker images -viz | dot -Tpng -o tree.png.
  • (5) Your login is stored in ~/.dockercfg. Remove it to logout.
  • (6) The TERM uses spaces to denote OR, so docker search "cassandra mysql" searches documents with cassandra or mysql in either the name or description of the image. A * means "followed later by the second term", but use grep for AND, like docker search --notrunc sql | grep -i centos. Alternately, use the Public Docker Indexwebpage to search.
  • (7) The docker run command also has this functionality.
  • (8) The image_set may be the top level public repository, like ubuntu; in an account of the public repostiory, like charlesmerriam/ubuntu; or in a private repostory, like localhost:5000/ubuntu.
  • (9) See http://golang.org/pkg/text/template/ for the Go Language template package.

Projects Related to Docker

Project Description
StackDock Hosting docker containers on SSD based hosts.
Wharf Try available services quickly using this open source Software as a Service.