Docker Commands: A Cheat Sheet

Containerization technologies have revolutionized the software development landscape. By allowing developers to package applications and their dependencies into isolated environments known as containers, they have simplified the development process, enabling applications to run consistently across various environments. Docker is one such example of a leading platform in the containerization space.

What does Docker do?

Docker’s purpose is to build and manage compute images and to launch them in a container. Docker enables managing microservices, facilitating efficient resource utilization, and accelerating application delivery, making it a vital tool for modern DevOps practices.

docker
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 images
docker container

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

docker images <COMMAND>
Docker container <COMMAND>

There are some basic docker commands:

View resources with ls

docker images ls
docker container ls

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

docker-container

Control timing with start, stop, restart, prune

docker container stop <container id>
docker container start <container id>
docker container restart <container id>
docker container prune <container id>

Name a container

docker run -d -name myfirstcontainer

View vital information: Inspect, stats, top

docker container inspect <container id>

docker container top <container id>

docker container stats <container id>

stats docker

top-docker

inspects-docker

Additional resources

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