What are containers? Explained with shipping containers
A container packs an app with everything it needs into one standard box, so it runs the same on any computer set up for it. Like a shipping container that fits on any ship.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- DevOps
In one sentence: A container is a standard, sealed package that holds an app together with everything it needs to run, so the same package can be shipped to a laptop, an office server or the cloud and behave the same way on each.
The everyday picture
Think about how goods travel by sea. Long ago, every load was a different shape: sacks, barrels, crates. Each port had to work out how to lift and stack them, and things went missing or broke.
Then came the standard shipping container. Every box has the same size and the same corner fittings. You pack your goods once, close the doors, and any ship, crane or truck built for that standard can carry it. The ship does not care what is inside.
Software containers work the same way. The app and everything it needs are packed into one standard box. Any computer set up to carry that kind of box can run it, without unpacking and repacking.
The developer writes a packing plan (the image) and stores it at the depot (the registry). Any server can fetch it and run identical containers from it for your users.
How it works, step by step
- The developer (the shipper) writes down exactly what goes in the box: the app's code, the tools and libraries it needs, its settings and the command that starts it.
- The container image (the packing plan) is built from that list. It is a read-only template. To change it, you build a new one, just as you would write a new plan rather than scribble on the old one.
- The registry (the depot) stores images so any server can fetch them. Docker Hub is a well-known public registry; companies also keep private ones.
- The server (the ship) pulls the image and starts a container from it: a running copy of the packed app. One image can start many identical containers, side by side on the same server.
- Each container is kept apart (each box has its own walls). It sees its own files, its own network settings, and it can be limited to a set share of memory and processing power. All the containers on one server share that server's operating system core, called the kernel (the ship's engine).
Try it · Everyday ↔ real
Match the shipping yard to the software
Switch between the two and see how each part lines up.
- The shipper
- The packing plan
- The depot
- The ship
- The ship's engine
- A loaded, sealed box
The shipping picture
| Everyday | Real |
|---|---|
| The shipper | The developer |
| The packing plan | The container image |
| The depot | The registry |
| The ship | The server |
| The ship's engine | The shared kernel |
| A loaded, sealed box | A running container |
Where the picture stops
- Steel boxes are fully sealed. Software containers share the server's kernel, so their walls are thinner. Microsoft notes that containers do not give as strong a security boundary as a virtual machine, which runs its own complete operating system.
- A box fits any ship, but a container needs the right kind of engine. Linux containers need a Linux kernel. On a Mac or Windows laptop, Docker Desktop quietly runs a small Linux virtual machine to carry them.
- Goods you add to a box during the trip stay there. Files a container writes are lost when that container is deleted, unless they are saved to separate storage called a volume.
Try it · Myth or fact
Containers: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
Why it matters for your business
- Fewer surprises at launch: the same image runs in testing and in the live system, so "it worked on my machine" problems become rarer.
- Lower running cost: containers carry only what the app needs. Google Cloud describes them as megabytes in size and starting in seconds, where virtual machines are gigabytes and take minutes, so one server can hold more of them.
- Freedom to move: a standard package can move between your own servers and different cloud providers with less rework.
- A risk to manage: an image holds a frozen copy of its tools. Security fixes mean rebuilding and redeploying the image, so someone needs to own that routine.
An example
Imagine a 20-person accounting firm with an in-house app for client invoices. It runs on one old server, and only one developer knows how to set it up. Moving it is risky, so nobody touches it.
The firm's developer packs the app into a container image and stores it in a private registry. Now a new laptop, a test server or a cloud server can all run the exact same box in minutes. When the old server fails, the firm starts the same container on a cloud server instead of rebuilding everything by hand.
Frequently asked questions
Is a container the same as Docker?
No. Docker is a popular set of tools for building, sharing and running containers. Containers are the general idea, and other tools can build and run them too.
What is the difference between a container and a container image?
The image is the read-only package, like a packing plan. A container is a running copy started from that image. One image can start many containers.
Are containers the same as virtual machines?
No. A virtual machine runs its own complete operating system, including its own kernel. Containers share the host's kernel, which makes them lighter and faster to start, but less strongly separated.
What is Kubernetes?
Kubernetes is a tool that manages many containers across many servers. It decides where each one runs and starts new copies when one fails, a bit like a port office planning which ship carries which box.
Related explainers
The DevDrift sets up cloud hosting and deployments for web platforms: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.