The Top 10 Docker Commands You Should Know

Essential | Top 10 Docker Commands

Ink Insight 🧘🏼
DevOps Dudes
4 min readMar 21, 2023

--

Photo by Ian Taylor on Unsplash

Docker is an open-source platform that helps developers build, ship, and run distributed applications. With Docker, you can package your application and all its dependencies into a single container, which can be deployed in any environment.

Today, we will discuss the top 10 basic Docker commands.

  1. docker run: This command is used to create and start a new container from an image. It takes an image name and a command to run in the container.

For example, docker run -p 80:80 nginx, This command will start an nginx container and map port 80 on the host to port 80 on the container. The container will run in the foreground until you stop it with Ctrl-C.

2. docker images: This command is used to list all the available images on your system.

For example, docker images will display the name, tag, and size of each image. This command is helpful when you want to see what Docker images you have on your system

3. docker ps: This command is used to list all the running containers on your system.

For example, docker ps will display the container ID, image name, status, and other details of each running container. This command is useful when you want to check which containers are currently running on your system.

4.docker stop: This command is used to stop one or more running containers. It takes one or more container IDs or names as arguments.

For example, docker stop my-container will stop the container with the name “my-container”. This command is useful when you want to stop a running container gracefully. You can use the docker kill command to force-stop a container.

5. docker start: This command is used to start one or more stopped containers. It takes one or more container IDs or names as arguments.

For example, docker start my-container will start the container with the name “my-container”.
This command is useful when you want to start a stopped container. You can use the docker restart command to stop and then start a container.

6. docker rm: This command is used to remove one or more containers. It takes one or more container IDs or names as arguments.

For example, docker rm my-container will remove the container with the name “my-container”.
This command is useful when you want to remove a stopped or running container.

7. docker rmi: This command is used to remove one or more images. It takes one or more image IDs or names as arguments.

For example, docker rmi my-image will remove the image with the name “my-image”.
This command is useful when you want to remove an image that’s no longer needed.

8. docker logs: This command is used to display the logs of a container. It takes a container ID or name as an argument.

For example, docker logs my-container will display the logs of the container with the name “my-container”.
This command is useful when you want to debug a container or check its output.

9. docker inspect: This command is used to display detailed information about a container or image.

For example, docker inspect container_id this command will display detailed information about a Docker container.
This command is helpful when you want to see detailed information about a Docker container or image.

10. docker exec: This command is used to run a command inside a running container.

For example, docker exec container_id ls will run the ls command inside a running Docker container. This command is helpful when you want to run a command inside a running Docker container.

Thanks for reading! I appreciate your support 👏 and engagement 🚙 in my stories. I’m always looking for ways to improve, so please feel free to leave a comment or share your thoughts.

--

--

Ink Insight 🧘🏼
DevOps Dudes

Discover the intersection of DevOps, InfoSec, and mindfulness with Ink Insight. Follow for valuable insights! ✍︎ 👨‍💻 🧘🏼