Top 10 Docker Commands Every Developer Should Know
Getting started with Docker can feel intimidating at first, but mastering just a few essential commands will quickly make you feel at home. In this post, you’ll learn the top 10 Docker commands that every developer should know — along with real-world examples and tips on how to explore Docker commands on your own.
How to View All Docker CLI Commands
Before diving into the top commands, you can explore everything Docker offers by simply running:
docker --help
This displays a full list of available commands like build
, run
, images
, ps
, and more.
Want help with a specific command? Just add --help
after it:
docker build --help
Top 10 Docker Commands Every Developer Should Know
1. docker --version
Check if Docker is installed and what version you’re using.
docker --version
Example Output: Docker version 24.0.5, build ced0996

2. docker build
Build a Docker image from a Dockerfile.
docker build -t myapp:latest .
-t
gives the image a name and tag.
means the Dockerfile is in the current directory
Use this when packaging your app into an image.
3. docker run
Run a container from an image.
docker run -d -p 3000:3000 myapp
-d
runs in detached mode (in the background)-p 3000:3000
maps host port to container port
Use this to launch apps, services, or scripts.
4. docker ps
List running containers.
docker ps
You’ll see the container ID, image name, uptime, and open ports.

5. docker ps -a
List all containers — running or stopped.
docker ps -a
Useful when debugging containers that exited unexpectedly.

6. docker exec
Execute a command in a running container.
docker exec -it myapp_container bash
-it
makes the shell interactivebash
opens a terminal session inside the container
Perfect for inspecting or debugging containers live.
7. docker logs
View logs from a container’s stdout.
docker logs myapp_container
Great for checking output, errors, or status of your app.
8. docker stop
Gracefully stop a running container.
docker stop myapp_container
This allows the container to shut down cleanly.

9. docker rm
Remove a container (must be stopped first).
docker rm myapp_container
Clean up containers you no longer need.
10. docker rmi
Remove a Docker image from your system.
docker rmi myapp
Frees disk space and helps reset your build environment.
Bonus: docker system prune
Clean up unused containers, images, networks, and caches.
docker system prune -f
-f
: skips confirmation
⚠️ Use with caution — this deletes all unused resources.
Example Workflow
Here’s a full cycle of building and running an app:
# 1. Build the image
docker build -t hello-world .
# 2. Run it
docker run -d -p 8080:80 hello-world
# 3. View logs
docker logs $(docker ps -q)
# 4. Stop and remove
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
To explore more Docker features:
docker image --help
docker container --help
docker compose --help
Each subcommand has its own set of options — all self-documented.
Learning Docker starts with the basics. These top 10 Docker commands — plus the ability to discover more via --help
— will give you the confidence to build, debug, and manage containers like a pro.
You can read more useful articles like How To Use Docker Compose: Multi-Container Applications.
Follow us for the more helpful posts!
We hope this is a useful post for you.