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 repository.

  • docker images

To get all the pulled images which is 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 which are available as well up and running.
The difference between docker ps and ps -a is that ps -a allows you see containers which are down as well.

  • docker run -it -d <image_name>

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

  • docker exec -it <container_id> bash

To run container in interactive mode using bash shell.

  • 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 mentioned <image_id>

  • docker inspect <container_id>

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


Hope you liked this cheat sheet. 🍻

Tirthankar Kundu

Tirthankar Kundu