10 Essential Docker Commands Every DevOps Professional Should Know
Photo by Rubaitul Azad on Unsplash
Docker simplifies containerization, making it a must-have tool for DevOps. Here are the key commands that you’ll use regularly:
docker pull – Download images from Docker Hub to your local system. For example, docker pull nginx fetches the latest Nginx image.
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.
docker ps – List all running containers. Add -a to see all containers, including stopped ones.
docker stop – Gracefully stop a running container by specifying its ID or name.
docker rm – Remove stopped containers to keep your environment clean.
docker rmi – Delete unused images to free up space on your machine.
docker exec – Run commands inside a running container. For example, docker exec -it [container-id] bash opens a shell.
docker build – Build a custom image from a Dockerfile using docker build -t [image-name] ..
docker logs – View the logs of a running or stopped container to troubleshoot issues.
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!