Docker in 10 Minutes: The Only Commands You Actually Need
By The IT Hustle Team
This article was generated with AI assistance and reviewed by our team for accuracy and quality. All technical information and examples have been verified.
Docker has a reputation for being complicated. It's not. The problem is that every tutorial starts with "Docker uses cgroups and namespaces to isolate processes in the Linux kernel" — and you close the tab before you learn anything useful.
Here's the truth: you need about 12 commands to use Docker for 95% of real work. The rest is edge cases and ops stuff you can Google when you need it.
This guide assumes you've installed Docker (docs.docker.com/get-docker) and have a terminal open. Let's go.
The Mental Model (30 Seconds)
Image = a blueprint (like a recipe)
Container = a running instance of that blueprint (like the cooked meal)
Docker Hub = a library of blueprints other people made (like a cookbook)
That's it. Everything else is details.
The 12 Commands You Need
1. docker pull — Download an Image
docker pull node:22
# Downloads the Node.js 22 image from Docker Hub
Like npm install but for entire environments.
2. docker run — Start a Container
docker run -it node:22 bash
# Starts a Node.js container and drops you into a shell
# -i = interactive, -t = terminal
3. docker run -d — Run in Background
docker run -d -p 3000:3000 --name myapp node:22
# -d = detached (runs in background)
# -p 3000:3000 = map port 3000 on your machine to 3000 in the container
# --name myapp = give it a name you can remember
4. docker ps — See What's Running
docker ps
# Shows all running containers
docker ps -a
# Shows ALL containers (including stopped)
5. docker stop / docker start — Control Containers
docker stop myapp
docker start myapp
6. docker logs — See What Happened
docker logs myapp
# Shows stdout/stderr from the container
docker logs -f myapp
# -f = follow (like tail -f)
7. docker exec — Run Commands Inside a Container
docker exec -it myapp bash
# Opens a shell inside a running container
# Great for debugging
8. docker build — Create Your Own Image
docker build -t my-app:v1 .
# -t = tag (name:version)
# . = use the Dockerfile in current directory
9. docker images — List Your Images
docker images
# Lists all images on your machine
10. docker rm / docker rmi — Clean Up
docker rm myapp
# Remove a stopped container
docker rmi node:22
# Remove an image
docker system prune
# Nuclear option: remove all unused containers, images, networks
11. docker-compose up — Multi-Container Apps
docker compose up -d
# Starts all services defined in docker-compose.yml
docker compose down
# Stops and removes everything
This is how you run a full stack locally — database, backend, frontend — with one command.
12. docker volume — Persist Your Data
docker run -v mydata:/app/data my-app
# -v = mount a volume so data survives container restarts
A Real-World Example: Postgres in 30 Seconds
# Start a Postgres database with one command:
docker run -d \
--name my-postgres \
-e POSTGRES_PASSWORD=secret \
-p 5432:5432 \
-v pgdata:/var/lib/postgresql/data \
postgres:16
# That's it. Connect at localhost:5432.
# Data persists because of the -v volume mount.
The Cheat Sheet
| What You Want | Command |
|---|---|
| Download an image | docker pull name:tag |
| Run interactively | docker run -it name bash |
| Run in background | docker run -d -p 3000:3000 name |
| See running containers | docker ps |
| Stop a container | docker stop name |
| View logs | docker logs -f name |
| Shell into container | docker exec -it name bash |
| Build your image | docker build -t name:tag . |
| Clean everything | docker system prune |
| Multi-container stack | docker compose up -d |
The Bottom Line
Docker isn't hard — it's just poorly explained. The mental model is simple: images are blueprints, containers are running instances. 12 commands cover 95% of daily use. Everything else you learn as you need it.
Start with docker run -it node:22 bash. You'll be inside a Node.js environment in 10 seconds. From there, you're a Docker user.
New to the command line? Read our 10 Command Line Tools That Will 10x Your Productivity and learn Unix File Permissions Explained for Humans.
We build free developer tools and write about AI, automation, and developer productivity. 30 tools, 33 articles, and an AI Prompt Engine — all built to help workers navigate the AI era. Published by Salty Rantz LLC.
The IT Hustle Weekly
What changed in AI this week and what it means for your job. Free tools, honest reviews, zero spam.
Generate Your Own Anti-Hallucination Prompts
Our AI Prompt Engine uses patent-pending technology to generate prompts with built-in verification and contradiction testing.
Try 3 Free Generations →