Table of contents
Docker basics: Essential commands
Software Engineer
Software Engineer
Docker
Docker
Docker has revolutionized the way we build, ship, and run applications. With its lightweight and portable nature, Docker containers have become the go-to solution for application deployment across different environments. In this blog post, we will walk you through some essential Docker commands that will empower you to navigate through the Docker ecosystem with confidence.
1. Docker Pull
The docker pull command allows you to fetch a specific image from a registry. For instance:
// language: bash docker pull <image-name>
This command will download the specified image, making it available on your local machine for container creation.
2. Docker Build
The docker build command allows you to create a custom Docker image based on a Dockerfile. For example:
2. Docker Build
The docker build command allows you to create a custom Docker image based on a Dockerfile. For example:
// language: bash docker build -t <image-name> <path-to-dockerfile>
This command will build an image using the instructions defined in the Dockerfile.
3. Docker Run
The docker run command is fundamental to Docker. It allows you to create and start a container from a specific image. For example:
3. Docker Run
The docker run command is fundamental to Docker. It allows you to create and start a container from a specific image. For example:
// language: bash docker run <image-name>
This command will pull the specified image (if it doesn't exist locally) and start a container based on it.
4. Docker PS
The docker ps command displays the running containers on your system. It provides information such as the container ID, image used, status, and port mapping. For example:
4. Docker PS
The docker ps command displays the running containers on your system. It provides information such as the container ID, image used, status, and port mapping. For example:
// language: bash docker ps
This command will show all the running containers.
5. Docker Stop
The docker stop command is used to halt a running container. You need to specify the container ID or name. For example:
5. Docker Stop
The docker stop command is used to halt a running container. You need to specify the container ID or name. For example:
// language: bash docker stop <container-id>
This command will gracefully stop the specified container.
6. Docker Exec
The docker exec command enables you to run a command within a running container. It is particularly useful for troubleshooting or interacting with containerized applications. For example:
6. Docker Exec
The docker exec command enables you to run a command within a running container. It is particularly useful for troubleshooting or interacting with containerized applications. For example:
// language: bash docker exec -it <container-id> <command>
This command will execute the specified command within the running container like /bin/bash
7. Docker Logs
The docker logs command retrieves the logs generated by a specific container. It helps in debugging and monitoring containerized applications. For example:
7. Docker Logs
The docker logs command retrieves the logs generated by a specific container. It helps in debugging and monitoring containerized applications. For example:
// language: bash docker logs <container-id>
This command will display the logs of the specified container.
8. Docker Images
The docker images command lists all the images available on your system. It provides information such as the image ID, repository, tag, and size. For example:
8. Docker Images
The docker images command lists all the images available on your system. It provides information such as the image ID, repository, tag, and size. For example:
// language: bash docker images
This command will show all the images present on your local machine.
Happy Dockerizing!
Happy Dockerizing!
Created at
2023-05-21 21:49:27 +0700
Related blogs
How Google achieves seamless SSO across multiple domains like Gmail and Youtube?
Hey there! Ever wondered how you can log into Gmail and then magically find yourself logged into YouTube, Google Drive, and all other Google services ...
Software Engineer
Software Engineer
2024-09-24 22:52:06 +0700
One Design Pattern a Week: Week 4
Welcome back to my "One Design Pattern a Week" series!
Try to solve this real problem: Request HandlingImagine you're building an enterprise applicati...
Software Engineer
Software Engineer
2024-10-28 16:46:15 +0700