LINUX KERNEL · SHAREDPYTHON 3.12PID42111CONTAINER · SHOPPYTHON 3.9PID43881CONTAINER · REPORTMEM 0 / 256 MiBHYPERVISORGUEST OS + KERNELAPP:80801docker run \2 -p 8080:8000 \3 --memory 256m \4 --cpus 0.5 \5 shop:1.0BROWSERHOST · pssystemd1shop4211report4388
Trays: two containers on one shared kernel (rose)Front: the docker run command, and the host's process listEnvelope: a request from the browser to shopTwo Python apps that would clash on one server, shop on Python 3.12 and report on Python 3.9, each in its own container. A container is an ordinary process walled off by the shared Linux kernel: namespaces give it its own files, process numbers and network, and control groups cap the memory and CPU it may use. At the back right, a virtual machine boots a whole guest OS with its own kernel. Containers as described here are a Linux kernel feature. Docker Desktop on macOS and Windows runs them inside a small Linux virtual machine; Windows also has its own Windows containers.

The idea

  1. One server must run two Python apps. Shop needs Python 3.12, report needs Python 3.9, and both listen on port 8000. Installed side by side they clash: one Python version wins, and only one app can own port 8000.

What it sees: namespaces

What it uses: cgroups

Containers and VMs

What happens

;; step 1/10 · clash
shop     needs Python 3.12, listens on :8000
report   needs Python 3.9,  listens on :8000

same server, no walls:
  one python3 on the PATH  → one app breaks
  2nd app on :8000 → OSError: Address already in use

Containers as described here are a Linux kernel feature. Docker Desktop on macOS and Windows runs them inside a small Linux virtual machine; Windows also has its own Windows containers. The PIDs 4211 and 4388 and the container ID 3f2a9c1e7b04 are example values; your machine prints its own. A process has one PID in each PID namespace it is visible in. The app is PID 1 only when the image starts it directly (exec form, CMD ["python", "app.py"]); in shell form, /bin/sh is PID 1.