What Is a Container?
Throughout this course you will package one small web app, quicknotes: a Python program that serves a notes page on port 5000. On your laptop it runs fine. The moment you want it to run the same way on a friend's laptop, a test server and a cloud machine, you need a container. So first, what is one?
The rule
A container is an ordinary process with a private view and a budget.
Take the rule apart:
- Ordinary process. When quicknotes runs in a container, it is still just a
pythonprocess on the host's own kernel. There is no second operating system underneath it. - Private view. The kernel shows that process its own filesystem, its own process list, its own network and hostname. From inside, it looks like it has a small machine to itself.
- A budget. The kernel can also cap how much CPU and memory the process may use.
The files it sees come from an image: a read-only package holding the app's code, the Python runtime, the libraries and a note about which command to start. The container is one running instance made from that image.
docker run -d -p 8080:5000 quicknotes:1.0That single line asks Docker to take the quicknotes:1.0 image and start a container from it. If you then list processes on the host, you will find the python process sitting there like any other program.
The shortcut
Think image : container = program file : running program. You can open the same program file many times and get several independent windows; you can start many containers from one image, and each gets its own thin writable space on top of the shared, unchanged image.
Find the image
Docker looks for
quicknotes:1.0locally and downloads it from a registry only if it is missing.
The common mistake is picturing a container as a "mini virtual machine". Ask the shortcut question: is there a second kernel booting? No. It is a program the kernel is showing a curated world to.
Drills
Answer fast — trust the rule.
Which description of a container is accurate?
You run docker run -d quicknotes:1.0 three times. What do you have?
Where does a container's kernel come from?
quicknotes writes a temporary file while running in a container. Where does that change go?
Remember
- A container is an ordinary process with a private view (files, processes, network) and a budget (CPU, memory).
- Image : container = program file : running program. One image, many containers.
- Trap: a container is not a small VM; it has no kernel of its own.
