$ python app.py✓ runspython 3.12flaskapp.pyv1web:v1v2web:v2KUBERNETES1FROM python:3.12-slim2RUN pip install flask3COPY app.py .4CMD ["python", "app.py"]LINUX KERNELweb:v1web:v2web:v1web:v2LINUX KERNELweb:v1web:v2web:v1web:v21APP_ENV=production2DB_HOST=db.internalHYPERVISORGUEST OSAPPv1v2
Image: read-only layers built from the Dockerfile, stored in the registry by name and tagContainers: running copies of the image on each server's one shared kernelMovers: the code alone, the image on its way, and the settingsAt the back: your laptop, the image build where the layers stack up, the registry and the Kubernetes orchestrator. In front: the Dockerfile, two servers whose Linux kernel carries the containers, the settings card and a virtual machine for comparison. Code alone crashes on the server. Packed as an image with its dependencies, it travels through the registry to the servers and runs the same everywhere; the orchestrator restarts a crash, adds a copy, rolls out v2 one container at a time and rolls back. The base image python:3.12-slim is itself several layers (a small Debian Linux plus Python 3.12); the figure draws it as one.

Package the app

  1. Your app runs fine on your laptop. Copy just the code to a server and it crashes: the server lacks the flask library your laptop happens to have. Code depends on its surroundings, and surroundings differ from machine to machine.

Ship and run

Run a fleet

Release safely

What happens

;; step 1/12 · my-machine
laptop   $ python app.py
         Python 3.12, flask installed   runs
server   $ python app.py
         ModuleNotFoundError: No module named 'flask'
same code, different surroundings

Kubernetes runs containers inside pods: a pod is one or more containers that share a network address. The figure shows one container per pod. Linux containers share the host's Linux kernel, and kernel features called namespaces and cgroups keep them apart. On Windows and macOS, Docker Desktop runs Linux containers inside a small Linux virtual machine that provides that kernel (Windows can also run Windows containers natively).