Complete Beginner's Guide to Docker
What Docker actually does, why it matters, and how to run your first container without getting lost in jargon.
Docker packages an application together with everything it needs to run (code, runtime, system tools, libraries) into a single unit called a container. This guide covers the core concepts and gets you running your first container.
Why Docker exists
Before containers, “it works on my machine” was a real and constant problem: an app might depend on a specific version of a language runtime, a system library, or an environment variable that only existed on one developer’s laptop. Docker solves this by packaging the entire runtime environment, so the same container behaves the same way everywhere.
Key concepts
- Image: a read-only template that defines what goes into a container (like a class in programming).
- Container: a running instance of an image (like an object created from that class).
- Dockerfile: a text file with instructions for building an image.
- Registry: a place to store and share images, like Docker Hub.
Installing Docker
Download Docker Desktop for macOS or Windows, or install Docker Engine directly on Linux. Verify the install with:
docker --version
Running your first container
Pull and run a simple web server:
docker run -d -p 8080:80 nginx
This downloads the official nginx image if you don’t already have it, starts a container in the background (-d), and maps port 8080 on your machine to port 80 inside the container. Visit http://localhost:8080 and you should see the default nginx welcome page.
Writing a Dockerfile
For your own application, you’ll typically write a Dockerfile rather than relying on a public image alone:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
Build and run it with:
docker build -t my-app .
docker run -p 3000:3000 my-app
Common commands you’ll actually use
docker ps: list running containers.docker ps -a: list all containers, including stopped ones.docker stop <container>: stop a running container.docker logs <container>: view a container’s output, useful for debugging.docker system prune: clean up unused images and containers to free disk space.
Where to go from here
Once running a single container feels comfortable, the natural next step is Docker Compose, which lets you define and run multi-container setups (an app, a database, a cache) from a single YAML file.
Affiliate disclosure
Some links in this article are affiliate links. If you buy something through them, we may earn a commission at no extra cost to you. This never affects which products we choose to cover or how we rate them. Read our full affiliate disclosure.
Written by
David OseiSenior Developer & Tutorials Lead
David writes the programming tutorials on Fieldnote. He builds and ships web projects for a living, and writes the guide he wishes he'd had the first time he tried each tool.
Newsletter
Get new field notes in your inbox.
Related articles
Notion vs. Obsidian: Which Should You Use in 2026?
Both are excellent note-taking tools built on very different philosophies. Here's how to decide which one fits the way you actually work.
What the New Core Web Vitals Update Means for Publishers
Search engines have adjusted how page experience factors into rankings. Here's what actually changed, and what to prioritize.
10 AI Tools Worth Trying in 2026
From writing assistants to code generation, these are the AI tools that have earned a permanent spot in our workflow this year.