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.
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.
Comments
Comments are coming soon. This section is a placeholder — wire it up to Giscus, Disqus, or a similar service when you're ready to accept discussion, all without adding a backend of your own.
Newsletter
Get new field notes in your inbox.