Docker Commands Quick Reference Cheat Sheet

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $ credit.
This credit will be applied to any valid services used during your first  days.

Docker is becoming increasingly popular among software developers, operators and enterprises as a software container platform. Containers package software in a format that can run isolated on a host operating system. Bundled with only essential libraries and settings, Docker renders lightweight, efficient, self-contained systems that run identically wherever deployed.

Optimizing the platform’s functionality begins with mastery of the core Docker commands. This cheat sheet is a reference for the most basic Docker commands that address installation, Hub interaction, and working with containers and images.

As of this writing, the recommended Docker installation is Docker Community Edition (Docker CE). See the official docs or our How to Install Docker guide for more details.

If you have not added your limited user account to the docker group (with sudo usermod -aG docker username), all of the commands in this cheatsheet will need to be run with sudo.

Docker Hub

Docker SyntaxDescription
docker search searchtermSearch Docker Hub for images.
docker pull user/imageDownloads an image from Docker Hub.
docker loginAuthenticate to Docker Hub
(or other Docker registry).
docker push user/imageUploads an image to Docker Hub.
You must be authenticated to run this command.

Image and Container Information

Docker SyntaxDescription
docker psList all running containers.
docker ps -aList all container instances, with their ID
and status.
docker imagesLists all images on the local machine.
docker history user/imageLists the history of an image.
docker logs [container name or ID]Displays the logs from a running container.
docker port [container name or ID]Displays the exposed port of a running container.
docker diff [container name or ID]Lists the changes made to a container.

Work With Images and Containers

Docker SyntaxDescription
docker run -it user/imageRuns an image, creating a container and
changing the terminal
to the terminal within the container.
docker run -p $HOSTPORT:$CONTAINERPORT -d user/imageRun an image in detached mode
with port forwarding.
ctrl+p then ctrl+qFrom within the container’s command prompt,
detach and return to the host’s prompt.
docker attach [container name or ID]Changes the command prompt
from the host to a running container.
docker start [container name or ID]Start a container.
docker stop [container name or ID]Stop a container.
docker rm -f [container name or ID]Delete a container.
docker rmiDelete an image.
docker tag user/image:tag user/image:newtagAdd a new tag to an image.
docker exec [container name or ID] shell commandExecutes a command within a running container.

Image Creation

Docker SyntaxDescription
docker commit user/imageSave a container as an image.
docker save user/imageSave an image to a tar archive.
docker build -t sampleuser/ubuntu .Builds a Docker image
from a Dockerfile
in the current directory.
docker loadLoads an image from file.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on

Your Feedback Is Important

Let us know if this guide was helpful to you.

Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.
The Disqus commenting system for Linode Docs requires the acceptance of Functional Cookies, which allow us to analyze site usage so we can measure and improve performance. To view and create comments for this article, please update your Cookie Preferences on this website and refresh this web page. Please note: You must have JavaScript enabled in your browser.