Blog / Topic

Containers

Containers · Part 9 ·

Where the shipping container picture breaks

The whole port in one picture, from the packing list to the gate. The picture stops being true in two places. Every container shares the host's kernel, and every container needs hardening of its own.

blindfoldsees itselfrationcgrouplayersimagetag + digestnamestrailervolumegateportthe whole port, in one pictureone kernel under every boxwalls are curtains:separated, not protecteda hole in the kernel reaches every boxharden each box
Containers · Part 8 ·

A compose.yaml for a real server

The compose file from part 6 works on a laptop. On a server it shows its password, lets logs fill the disk and stays stopped after a crash. A few lines fix that. An override file keeps the laptop setup easy to work with.

memory: 512m and no morepassword: a file,not in docker inspectcrashes? starts againrestart: unless-stoppedlogs cut at 10 MBZZ3 a.m.: nobody awakethe file keeps watch
Containers · Part 7 ·

What a good Dockerfile looks like

A first Dockerfile works, and ships a 1.38 GB image that runs as root and takes ten seconds to stop. A build stage, a non-root user and the exec form fix all three.

the workshop: 1.38 GBcompiler, Debian, sourceCOPY --fromships: 17.8 MBonly the programUSER nonrootnot root insideENTRYPOINT ["/app"]SIGTERM reaches the app: stops in 0.1 sshell form: 10 s
Containers · Part 6 ·

Why Compose is more than a shortcut

A real app is several boxes that need each other. Compose describes them in one file, with their trailers, their gates and their start order. That plan stays where you can read it next month.

compose.yamlweb:  ports: 8080  depends_on: dbdb:  volume: dbdata  healthcheckthe loading plankept in Git, not typed oncewebdbdbfind each other by namestarted is not ready:web waits for a healthy db
Containers · Part 5 ·

What volumes and ports are for

A container's own files are deleted with the container, and nothing outside can reach the container until you open a gate. A volume keeps the data. A published port opens the gate, and its address decides who can come in.

its own top sheet:gone on docker rmpgdatavolume: a trailerstays when the box goesbind mount:a door to your foldersdev only-p 8080:80open to everyone127.0.0.1:8080:80this machine onlyports: a gate
Containers · Part 4 ·

What actually happens when you type docker run

docker run only sends a message. We look at who receives it, who asks the kernel for the blindfold and the limit, and why anyone who can send that message is root.

rundocker: only a clientthe hatchdocker.sockdockerd: rootcontainerdrunc starts itand leavesshimstays as parentreach the hatch = be rootthe docker group is root tooKubernetes skips Docker:it talks to containerd
Containers · Part 3 ·

Why latest is not a version

A sealed box waits in a depot until a server asks for it by name. A tag can point at a different image tomorrow, and a digest always names exactly one image.

registry: the depotMondayTuesdaylatesta tag is a paper label: it can movelatest =no tag givendigest: a fingerprintsha256:9e01…exactly one imagechecked on every pull
Containers · Part 2 ·

What's inside a Docker image

An image is a sealed box made of stacked layers. The order of lines in your Dockerfile decides how long a rebuild takes, and a deleted secret is still inside the image.

DockerfileFROM alpineCOPY deps.txt .RUN install depsCOPY . .one line = one layer1234alpine1deps.txt2deps3your code4container writes herereused from cachenothing changed hereredrawnonly the code changeddeps first, code lastso a code edit keeps the depskey.pemdeleted files still ship
Containers · Part 1 ·

A container is just a process

A container is an ordinary process on your machine with a blindfold and a ration. What that means, and why a container starts in a few hundred milliseconds while a full Linux VM on a laptop takes tens of seconds to boot.

your machineone kernel, shared by allprocessprocess64 MBprocess tooblindfold:sees only itselfration:this muchstarts in 0.3 sa VMappguest OSits own kernelfake hardwareboots in 30 s

New posts by email

One email when a post ships, about twice a month. Nothing else, and one click to leave.

Latest: Finding where a request breaks · RSS