Cheat Sheet Docker



Docker’s purpose is to build and manage compute images and to launch them in a container. So, the most useful commands do and expose this information.

Do not expose the Docker daemon socket (even to the containers)¶ Docker socket. Given our affinity for Docker, we wanted to pass along some tips and best practices for using it at the command-line. To do that we’ve created a convenient Docker Commands Cheat Sheet to help improve your work flow. Now, you can avoid having to search for these shortcuts every time you open the software. Windows Docker Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets.


Here’s a cheat sheet on the top Docker commands to know and use.

(This is part of our Docker Guide. Use the right-hand menu to navigate.)

Images and containers

The docker command line interface follows this pattern:
docker <COMMAND>

Docker Command Cheat Sheet

The docker images and container commands grant access to the images and containers. From here, you are permitted to do something with them, hence:

There are:

Sheet
  • is lists the resources.
  • cp copies files/folders between the container and the local file system.
  • create creates new container.
  • diff inspects changes to files or directories in a running container.
  • logs fetches the logs of a container.
  • pause pauses all processes within one or more containers.
  • rename renames a container.
  • run runs a new command in a container.
  • start starts one or more stopped containers.
  • stop stops one or more running containers.
  • stats displays a livestream of containers resource usage statistics.
  • top displays the running processes of a container.

View resources with ls

Cheat Sheet Docker

Docker command line cheat sheet

From the container ls command, the container id can be accessed (first column).

Control timing with start, stop, restart, prune

  • start starts one or more stopped containers.
  • stop stops one or more running containers.
  • restart restarts one or more containers.
  • prune (the best one!) removes all stopped containers.

Name a container

Docker build cheat sheet

View vital information: Inspect, stats, top

  • stats displays a live stream of container(s) resource usage statistics
  • top displays the running processes of a container:
  • inspect displays detailed information on one or more containers. With inspect, a JSON is returned detailing the name and states and more of a container.

Additional resources

Cheat Sheet Docker Examples

Docker

Docker Command Line Cheat Sheet

For more on this topic, there’s always the Docker documentation, the BMC DevOps Blog, and these articles: