DevLabs Alliance - WhatsApp
DevLabs Alliance Logo

Home / Blogs /Essential Docker Co...

Essential Docker Commands - Cheat Sheet

John Doe

2024-07-25

DevLabs Alliance Blogs

0 mins read

Essential Docker Commands Cheat Sheet – That Every Developer Should Know


Docker is a powerful platform for developing, shipping, and running applications using containerization. It allows developers to package applications and their dependencies into containers, ensuring consistency across various environments from development to production. This portability reduces the "it works on my machine" problem, streamlines collaboration, and speeds up deployment cycles. Docker's lightweight and scalable nature makes it ideal for microservices architecture, improving resource utilization and operational efficiency. In today's fast-paced tech landscape, Docker plays a vital role in enabling continuous integration and continuous deployment (CI/CD), simplifying cloud migration, and fostering a robust DevOps culture, ultimately driving innovation and agility in software development.


Here are some frequently used Docker commands or cheat sheet along with brief explanations:

Docker Commands for Images

1. docker pull <image>:

- Pulls an image from a registry (e.g., Docker Hub).


2. docker images:

- Lists all images stored locally.


3. docker build -t <image_name> .:

- Builds an image from a Dockerfile in the current directory.


4. docker rmi <image>:

- Removes one or more images.

Docker Commands for Containers

1. docker run <image>:

- Runs a command in a new container from the specified image.


2. docker ps:

- Lists all running containers.


3. docker ps -a:

- Lists all containers, including stopped ones.


4. docker stop <container>:

- Stops a running container.


5. docker start <container>:

- Starts a stopped container.


6. docker restart <container>:

- Restarts a running or stopped container.


7. docker rm <container>:

- Removes one or more stopped containers.


8. docker exec -it <container> <command>:

- Runs a command in a running container (interactive terminal).

Docker Commands for Volumes

1. docker volume create <volume_name>:

- Creates a new volume.


2. docker volume ls:

- Lists all volumes.


3. docker volume rm <volume_name>:

- Removes one or more volumes.

Docker Network Commands

1. docker network create <network_name>:

- Creates a new network.


2. docker network ls:

- Lists all networks.


3. docker network rm <network_name>:

- Removes one or more networks.

Docker Compose Commands

1. docker-compose up:

- Builds, (re)creates, starts, and attaches to containers for a service defined in a docker-compose.yml file.


2. docker-compose down:

- Stops containers and removes containers, networks, volumes, and images created by up.


3. docker-compose build:

- Builds or rebuilds services.


4. docker-compose logs:

- Displays log output from services.

Miscellaneous

1. docker login:

- Logs in to a Docker registry.


2. docker logout:

- Logs out from a Docker registry.


3. docker info:

- Displays system-wide information about Docker.


These commands cover a wide range of Docker functionalities for managing images, containers, volumes, networks, and more. Feel free to share commands that you’re using, we will add them in this cheat sheet.

Know Our Author

DevLabs Alliance Author Bio

John Doe


DevLabs Alliance TwitterDevLabs Alliance LinkedInDevLabs Alliance Instagram

Author Bio

John Doe is a seasoned software engineer with over a decade of experience specializing in software development. He holds a Bachelor's degree in Computer Science. John is also passionate about sharing his knowledge and regularly contributes to online forums and blogs on various IT-related topics.

INQUIRY

Want To Know More


Email is valid



Phone


By tapping continuing, you agree to our Privacy Policy and Terms & Conditions

“ The hands-on projects helped our team put theory into practice. Thanks to this training, we've achieved seamless collaboration, faster releases, and a more resilient infrastructure. ”
DevLabs Alliance Blogs Page Review
Vijay Saxena

SkillAhead Solutions

DevLabs Alliance Footer section
DevLabs Alliance LinkedIn ProfileDevLabs Alliance Twitter ProfileDevLabs Alliance Facebook ProfileDevLabs Alliance Facebook Profile
DevLabs Alliance Logo

USA

1603, Capitol Avenue, Suite 413A, 2659, Cheyenne, WY 82001, USA

DevLabs Alliance ISO 9001

DevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer SectionDevLabs Alliance Footer Section

`Copyright © DevLabs Alliance. All rights Reserved`

|

Refund & Reschedule Policy

Privacy Policy

Terms of Use