Docker for Developers: What You Actually Need to Know
Docker feels complex until you understand the three core concepts. Here's a practical intro that skips the theory and gets you running containers.
Docker clicked for me the moment I stopped thinking about it as 'containers' and started thinking about it as 'reproducible environments.' The problem Docker solves is real: 'works on my machine' is useless when you're collaborating or deploying. Docker makes environments explicit and repeatable.
The Three Concepts That Actually Matter
Everything in Docker flows from three things: images (blueprints), containers (running instances), and Dockerfiles (instructions to build an image). That's it. Everything else — volumes, networks, Docker Compose — is built on these.
Your First Dockerfile
A Dockerfile is a text file with sequential build instructions. Each instruction creates a layer in the image. Here's a realistic Node.js Dockerfile:
- FROM node:20-alpine — start from an official Node.js image (Alpine = small)
- WORKDIR /app — set working directory inside the container
- COPY package*.json ./ — copy dependency manifests first
- RUN npm ci — install dependencies (this layer is cached when dependencies don't change)
- COPY . . — copy your application code
- EXPOSE 3000 — document which port the app uses
- CMD ["node", "server.js"] — command to run when container starts
Docker Compose for Local Development
For any project with more than one service, use Docker Compose. A simple web app with a database becomes two services in docker-compose.yml: your app and a PostgreSQL container. Define both, run docker-compose up, and they start together on the same network. No manual network configuration, no port conflicts, no 'which postgres am I connecting to.'
The Commands You'll Use 90% of the Time
- docker-compose up -d — start all services in the background
- docker-compose down — stop and remove containers
- docker-compose logs -f [service] — tail logs from a service
- docker ps — list running containers
- docker exec -it [container] sh — open a shell inside a running container
- docker build -t myapp . — build an image from current directory
Common Gotchas to Avoid
Layer caching is Docker's superpower but also its footgun. If you COPY your entire project before installing dependencies, npm install runs every time any file changes. Always copy package.json first, install dependencies, then copy the rest. This way the dependency layer is cached as long as package.json doesn't change.
Use .dockerignore
Create a .dockerignore file (same syntax as .gitignore) to exclude node_modules, .git, and other large directories from the build context. This dramatically speeds up builds and reduces image size.
Frequently Asked Questions
Do I need Docker as a frontend developer?+
What's the difference between a Docker image and a container?+
Is Docker Compose different from Docker?+
How is Docker different from a virtual machine?+
🔧 Free Tools Used in This Guide
FreeToolKit Team
FreeToolKit Team
We build free browser-based tools and write practical guides that skip the fluff.
Tags: