10 Essential Docker Commands Every DevOps Professional Should Know

Docker simplifies containerization, making it a must-have tool for DevOps. Here are the key commands that you’ll use regularly:

  1. docker pull – Download images from Docker Hub to your local system. For example, docker pull nginx fetches the latest Nginx image.

  2. docker run – Start a container from an image. Running docker run -d -p 8080:80 nginx starts Nginx in detached mode, mapping port 8080 to 80.

  3. docker ps – List all running containers. Add -a to see all containers, including stopped ones.

  4. docker stop – Gracefully stop a running container by specifying its ID or name.

  5. docker rm – Remove stopped containers to keep your environment clean.

  6. docker rmi – Delete unused images to free up space on your machine.

  7. docker exec – Run commands inside a running container. For example, docker exec -it [container-id] bash opens a shell.

  8. docker build – Build a custom image from a Dockerfile using docker build -t [image-name] ..

  9. docker logs – View the logs of a running or stopped container to troubleshoot issues.

  10. docker-compose up – Start multiple containers defined in a docker-compose.yml file. Use -d to run in detached mode.


Mastering these commands will streamline your workflow and boost your efficiency in managing containers. Give them a try and see how much easier Docker can make your development and deployment process!