Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Introduction  ›  Lesson

What Is a Container?

What are Containers? 12 minA container is a normal process on the host's kernel that gets a private view of the system and a resource budget, started from a read-only image.

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 python process 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.0

That 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.

What happens on docker run quicknotes:1.0Step 1 of 4
  1. Find the image

    Docker looks for quicknotes:1.0 locally 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.

quick drill

Which description of a container is accurate?

quick drill

You run docker run -d quicknotes:1.0 three times. What do you have?

quick drill

Where does a container's kernel come from?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainExplain a container to a teammate

A teammate says 'a container is just a tiny virtual machine'. Using quicknotes as the example, explain what a container actually is, how it relates to an image, and what is wrong with the teammate's description.