Docker explained: what containers are and why developers use them
Containers package an application together with everything it needs to run: code, runtime, libraries and configuration. Docker popularized the approach and remains the most familiar tool.
The problem containers solve "It works on my machine" happens because development, testing and production environments differ. A container image bundles the environment, so the app runs the same way everywhere.
Containers vs virtual machines
- VMs emulate an entire computer with its own operating system kernel, which is heavier but strongly isolated
- Containers share the host's kernel and isolate processes, making them lightweight and fast to start
- Many production setups run containers inside VMs for extra isolation
Key concepts
- Image: a read-only template built from a Dockerfile
- Container: a running instance of an image
- Registry: a place to store and share images
- Volumes: persistent storage that outlives a container
- Compose: a tool for defining multi-container setups, like an app plus a database
Good practices
- Use small, trusted base images
- Do not bake secrets into images
- Run as a non-root user
- Pin versions for reproducible builds
- Scan images for known vulnerabilities
How do you use containers day to day: just for local development, or all the way to production? What Dockerfile tip saved you the most time?
Comments · 3
The business value is consistency: 'works on my machine' becomes a lot less common, and onboarding new developers gets faster.
Coming from outside, the shipping container analogy actually helps. Same box regardless of what's inside.
When would you not use containers? For a tiny project it can feel like overhead.