Basic Docker Commands CheatSheet

Basic Docker Commands CheatSheet

Docker has become an indispensable tool in the world of software development and deployment. It enables developers to create, deploy, and run applications in lightweight, portable containers. Whether you're a seasoned Docker user or just getting started, having a cheat sheet of basic Docker commands can be incredibly helpful. In this guide, we'll provide you with a handy Docker command cheat sheet to keep at your fingertips.

Prerequisites

Before you dive into Docker commands, make sure you have Docker installed on your system. You can download and install Docker from the official Docker website.

Docker Basics

1. Check Docker Version

To verify that Docker is installed and see its version:

docker --version

2. Display Docker Info

For detailed information about your Docker installation:

docker info

3. List Running Containers

To see the list of running containers:

docker ps

4. List All Containers

To see all containers, including stopped ones:

docker ps -a

5. Pull Docker Image

To download a Docker image from a registry (e.g., Docker Hub):

docker pull <image_name>

6. Search for Docker Images

To search for Docker images on Docker Hub:

docker search <image_name>

7. Run a Docker Container

To start a container based on an image:

docker run <image_name>

Add the -d flag to run the container in detached mode.

8. Stop a Running Container

To stop a running container gracefully:

docker stop <container_id>

9. Remove a Container

To remove a stopped container:

docker rm <container_id>

10. Remove an Image

To remove a Docker image:

docker rmi <image_name>

11. List Docker Images

To list all locally available Docker images:

docker images

12. Display Container Logs

To view the logs of a running container:

docker logs <container_id>

13. Execute Commands Inside a Container

To run a command inside a running container:

docker exec -it <container_id> <command>

14. Copy Files To/From a Container

To copy files to/from a container:

docker cp <file> <container_id>:<destination_path>

15. Inspect Container/Network/Volume

To view detailed information about a container/network/volume:

docker inspect <container_id>/<network_name>/<volume_name>

Conclusion

This Docker command cheat sheet provides a quick reference to essential Docker commands that every developer should be familiar with. Docker simplifies the process of building, deploying, and scaling applications, making it a valuable tool for modern software development.

Note

Remember that this is just the tip of the iceberg when it comes to Docker's capabilities. As you become more experienced with Docker, you'll discover many more advanced commands and features to enhance your containerization workflow. Docker's official documentation is a fantastic resource to explore those advanced topics further.

Happy Dockerizing! 🐋 See you in next post. Don't forget to comment your thoughts for this post. Share knowledge with others...

Let's Connect on:

Share :

Related Posts

A Step-by-Step Guide to Saving AWS Costs by Uploading Public Docker Images to Private ECR

A Step-by-Step Guide to Saving AWS Costs by Uploading Public Docker Images to Private ECR

In the world of containerized applications, Docker Hub is a popular choice for storing and sharing Docker images. While Docker Hub is a convenient option, it may not be the most cost-effective choice

read more
Kubernetes: The Future of Cloud Computing

Kubernetes: The Future of Cloud Computing

In the world of modern software development and deployment, Kubernetes has emerged as a powerhouse that is changing the way we manage and scale applications. Whether you are a seasoned developer or a

read more
From Dockerfile to Docker Compose: A Comprehensive Guide in Containerization

From Dockerfile to Docker Compose: A Comprehensive Guide in Containerization

Containerization has revolutionized the way we develop, deploy, and manage applications. Docker has been at the forefront of this containerization movement, simplifying the process of packaging an ap

read more
How to inspect the docker image?

How to inspect the docker image?

When it comes to Microservice architecture, the docker image is like the soul of the system. It is essential to understand the purpose of a docker image and what it contains so that you can use the r

read more
OOPS Concept in Simple English with Examples

OOPS Concept in Simple English with Examples

OOP is a way of writing computer programs that makes it easier to manage and organize your code. Let's break down some key OOP concepts: 1. Class: Think of a class as a blueprint or a templ

read more
What are Micro-service and Monolithic Architecture?

What are Micro-service and Monolithic Architecture?

Introduction: In the world of software development, architecture plays a crucial role in determining the scalability, maintainability, and flexibility of an application. Two popular architectu

read more
What is Docker and its use case?

What is Docker and its use case?

Docker is a powerful tool that has revolutionized the way applications are deployed and managed. It is an open-source platform that allows developers to build, package, and deploy applications in a c

read more
What is the docker multi-stage build?

What is the docker multi-stage build?

Although Docker eliminates the need for dependencies on the client system, inefficient building of the image can result in a heavy image size. Many developers are unaware of this feature, leading to

read more
A Comprehensive Guide to Docker Swarm: Orchestrate Your Containers with Ease

A Comprehensive Guide to Docker Swarm: Orchestrate Your Containers with Ease

In the world of containerization and microservices, managing and scaling containers efficiently has become a critical task. Docker Swarm, a native clustering and orchestration solution for Docker con

read more