If you’re working with containerized applications, understanding Docker is no longer optional — it’s a core skill for modern developers. Whether you’re a backend engineer deploying APIs or a full-stack developer managing dev environments, Docker can simplify your workflows dramatically.
In this guide, we’ll break down the most essential Docker commands, explain what each one does, and provide practical examples you can use every day.
🐳 Why Developers Use Docker
Docker helps developers package code and dependencies into lightweight, portable containers. These containers behave the same way across machines, environments, and even cloud platforms — eliminating the infamous “it works on my machine” problem.
But to unlock its full potential, you need to know your way around Docker commands.
📦 Getting Started with Docker CLI
Let’s go over the core commands every developer should know.
🔍 Check Docker Installation
docker --version
This shows the currently installed version of Docker. It’s the first command to run if you’re verifying an installation.
📥 Pull Docker Images
docker pull <image-name>
Download an image from Docker Hub (or another container registry).
Example:
docker pull node:latest
📃 List Docker Images
docker images
See all Docker images stored on your local machine.
❌ Remove a Docker Image
docker rmi <image-name>
Delete an unused image to free up space.
🚀 Run a Docker Container
docker run [options] <image-name>
Start a new container from a specified image.
Popular Options:
-d: Run container in detached (background) mode-p: Map ports from host to container (-p 8080:80)--name: Assign a custom name to the container
Example:
docker run -d -p 3000:3000 --name myapp node
📋 List Running Containers
docker ps
Displays all currently running containers.
To view stopped ones too:
docker ps -a
🧑💻 Execute Commands Inside a Running Container
docker exec -it <container-name> <command>
Open an interactive shell session in a running container.
Example:
docker exec -it myapp bash
⏹️ Stop, Start, Restart a Container
- Stop a container:
docker stop <container-name>
- Start a stopped container:
docker start <container-name>
Restart a container:
docker restart <container-name>
🐛 View Container Logs
docker logs <container-name>
Useful for debugging what’s going on inside a container.
🌐 List Docker Networks
docker network ls
Displays all networks defined in your Docker environment.
💾 List Docker Volumes
docker volume ls
See all data volumes used for persistent storage in containers.
📦 Using Docker Compose
For multi-container applications, docker-compose is your best friend.
- Start services:
docker-compose up
Stop and remove services:
docker-compose down
These commands rely on a docker-compose.yml file that defines the services, images, ports, and volumes.
🧠 Final Thoughts
Docker isn’t just a buzzword — it’s a real productivity booster that helps developers:
- Build consistent dev/test environments
- Reduce “works on my machine” bugs
- Ship apps faster and more reliably
By learning these essential Docker commands, you’ll be able to build, run, test, and manage containers with confidence.
Start small, get comfortable with the CLI, and build from there. The more you use Docker, the more indispensable it becomes in your developer toolkit.