GuidesDevOps
Docker for a small web project: useful or overkill?
Three words to know
- DockerfileThe recipe: base system, dependencies, start command.
- ImageThe result, frozen and versioned.
- ContainerA running image. You can start several.
When Docker is worth it
| Project | Docker? | Why |
|---|---|---|
| Static site | Rarely | Files served by Caddy or a CDN are enough |
| API + database + queue | Yes | docker compose starts everything in one command |
| Several developers | Yes | The same environment for all |
| A specific system tool version | Yes | It is frozen in the image |
A minimal docker compose
services:
api:
build: .
env_file: .env
ports: ["3000:3000"]
depends_on: [db]
db:
image: postgres:16
volumes: ["db-data:/var/lib/postgresql/data"]
volumes:
db-data:
The volume keeps the data when the container is recreated. Backups remain essential: see back up your database every night. For the server, Hosting on a VPS.
Frequently asked questions
- Does Docker slow the app down?
- Very little on Linux, where containers share the system kernel. The cost is mostly learning and maintaining images.
- Docker or virtual machine?
- A virtual machine carries a full system. A container holds only the app and its dependencies: lighter, faster to start.
- Do I need Kubernetes?
- Not for a small project. One server with docker compose is enough for a long time.