Docker Cheat Sheet

Docker Cheat Sheet

Docker is a revolution in the IT landscape and has made things easy.

It disallows developers to claim: "It works on my machine 😄"

Here, I created a cheat sheet I use to work with Docker

Frequently used commands

  • docker --version

It shows the docker version installed.

  • docker pull <image_name>

It allows you to pull images from the repository.

  • docker images

To get all the pulled images that are available locally.

  • docker ps

It allows you to see all the containers which are up and running.

  • docker ps -a

It allows you to see all the containers that are available as well up and running.
The difference between docker ps and ps -a is that ps -a allows you to see containers that are down as well.

  • docker run -it -d <image_name>

To Create a Docker Container from Docker Image in a detached mode.

  • docker exec -it <container_id> bash

To run the container in interactive mode using bash shell.

Tip: you can use part of the container_id too

  • docker start <container_id>

To start a container with mentioned <container_id>.

  • docker restart <container_id>

To restart a container with mentioned <container_id>.

  • docker stop <container_id>

To stop a container with mentioned <container_id>.

  • docker rm <container_id>

To delete a container with mentioned <container_id>.

  • docker rmi <image_id>

To delete a docker image with the mentioned <image_id>

  • docker inspect <container_id>

To give details on the container id. It is JSON data with all the details of the container


Hope you liked this cheat sheet. 🍻