“It works on my machine.” Every developer has said it, and everyone who runs servers has heard it. Your app runs fine on your laptop, then crashes on the server: a different Python version, a library nobody installed, a setting that only lived on your laptop. Docker exists to end that excuse. In this post I explain what Docker is, how a Dockerfile becomes an image and then a container, and why a container is not just a small virtual machine.
The shipping container idea
Ports had the same mess once. Before containerization, cargo was handled piece by piece: every crate a different shape, loaded by hand. Then came one standard steel box, the same size for every ship, train and truck, and nobody had to care what was inside to move it.
Docker does that for software. The box is called a container: your app plus everything it needs to run, packed the same way wherever it goes.
From Dockerfile to image to container
- Write a Dockerfile. It’s the packing list. Each line is an instruction:
FROMpicks the base image,COPYbrings in your files,RUNexecutes build commands, andCMDsets the command that runs when it starts.
FROM python:3-slim
COPY . /app
RUN pip install -r /app/requirements.txt
CMD ["python", "/app/app.py"]
- Build the image. Docker turns the Dockerfile into an image: a package with everything your app needs. Each instruction that changes files adds a layer, and image layers are read-only, so the image is sealed.
docker build -t your-user/my-app .
- Run a container. A container is a running copy of that image. Docker adds a thin writable layer on top of the read-only ones, so the image itself never changes. Run it three times and you get three containers from the same image.
docker run your-user/my-app
“Isn’t that just a virtual machine?”
Not quite. A virtual machine carries a full copy of an operating system, plus the app and its libraries. That’s tens of gigabytes, and VMs can be slow to boot.
Containers share the host’s kernel. There’s no second operating system inside, so images are typically tens of megabytes and containers start quickly.
The kernel keeps them apart with two Linux features:
- Namespaces give each container its own view of the system (its processes, its network, its files), as if it were alone.
- cgroups limit and monitor how much CPU and memory each one uses.
Ship it anywhere
Once the image is built, push it to a registry like Docker Hub. Any server can pull the exact same image and run it.
docker push your-user/my-app
docker pull your-user/my-app
So, no more “works on my machine”?
Mostly. Your laptop, the test server and production run the same image, with the same versions and the same settings. And when something breaks, at least it breaks the same way everywhere, which makes it much easier to find.
If you’re wondering who keeps those containers running once they’re in production, that’s the next step: AWS ECS tutorial: who keeps your container running at 3 a.m.?
Found it useful? Watch the short video on YouTube and subscribe to @Andrevops for more videos like this one.




