Chapter 1
Why Docker?
The "works on my machine" problem
You build an app on your laptop with Python 3.11 and a handful of system libraries. You ship it to staging. It crashes — wrong Python version, missing libssl, the database client behaves a little differently. The classic "works on my machine" story. Docker packages your app along with everything it needs into a single container that runs the same way anywhere.
Without Docker
Works on the dev's laptop
Push code to staging server
ImportError: wrong Python version
libssl version mismatch — DB fails
Two hours of manual fixes later…
With Docker
App + deps packaged into one image
docker push to a registry
docker pull on staging
Same container, same environment
Running. First try. Every time.
Key takeaways
- Containers package an app with all its dependencies — code, runtime, libraries
- The same image runs identically on a laptop, a staging server, or a cloud VM
- No more dependency hell or environment drift between machines
- Lightweight enough to start in milliseconds, not minutes