Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

DevOps the lesson

The Shipping Container (Docker) a show in 8 chapters

Goal: ship an app that starts unchanged on another machine, and keep 3 apps in the disk of 1

1 of 8 Your guess

Before we start

Your program runs fine on your own laptop. You hand it to a server, a computer somewhere else that runs it for other people, and there it falls over.

A tool called Docker is how most software makes that trip now. Which picture is closest to what it sends?

Pick the closest. You find out which fits at the end.

truckdockship's holdhandoffhandoffloaded by hand, one piece at a timea ship could sit in port for days

2 of 8 The problem

1956: cargo, loaded by hand

Before 1956, a ship left port carrying crates, barrels and sacks, every one a different shape. Dockworkers carried them aboard by hand, one at a time.

A ship could sit in port for days. Cargo broke, went missing or got stolen at almost every handoff between truck, dock and hold.

Step 1 of 3

your laptopthe serverappapplibrarylibraryrunsbreaksthe same app, a different version of its librarythe shapes stand for versions: they no longer fit

3 of 8 The idea

2013: two commands

A small hosting company called dotCloud kept hearing one complaint. An app ran fine on a customer's laptop and broke on dotCloud's servers.

The reason was usually a library, code the app borrows instead of writing itself. The server had a different version of it than the laptop did.

Your goal: ship an app so it starts unchanged on another machine, with no setup there. Then keep 3 apps in about the disk space of 1.

Step 1 of 4

nothing built yet

4 of 8 The idea

Stacked sheets

An image is not built in one shot. Its recipe, a file called a Dockerfile, is a short list of steps. Most steps lay one more sheet of files on top of the ones before.

A byte is the smallest unit a file is measured in. One character of text is about one byte.

Press Run line 1. Watch the stack.

Why is line 3 not a sheet?

A sheet holds files, and line 3 writes none. It only records what to run when a container starts, so it rides along as a note on the image. The lesson's image lists exactly 2 sheets.

Step 1 of 3

app.txt holds these 10 bytes

its fingerprint, worked out on this page

64 digits, each one of 16 (0 to 9, a to f) · each digit is 4 bits, a bit being one 0 or 1 · 64 × 4 = 256 bits

5 of 8 The fix

One sheet, kept once

Run a file's bytes through a fingerprint function and you get one 64 digit number. Change a single byte and the whole number changes.

Docker's function is called SHA-256, and the fingerprint it gives is a hash.

One file, one 64 digit fingerprint.

Could two different files get the same 64 digits?

There are 2256 possible fingerprints, a number 78 digits long. Even 1020 files, far more than were ever built into any image, would hit an accidental match with a chance of about 4 in 1038: never, in practice.

Step 1 of 4

the host: the machine the containers run onchip: the processorkernel: the operating system's corecontainer 1its own filesno kernel insidecontainer 2its own filesno kernel inside

6 of 8 The cost

Where the box stops

An image holds files, nothing else. When a container runs, its files are read by the operating system already running on the host.

The core of that operating system, the part every program asks for files, memory and time, is the kernel. The image never packs one of its own.

So "identical everywhere" means the files are identical. What reads them is whatever the host already has. That is why a container is not a virtual machine, a whole pretend computer that does pack its own.

Step 1 of 4

7 of 8 Your guess

Your picture now

Goal met: one image starts unchanged on another machine with the same kind of chip, and 3 images sit in 8,822,743 bytes, the base plus 46. Which picture is closest now?

Pick one.

The shipping container (Docker)Everyone agrees on the box, so nobody asks what is inside.123Image, containeryour code: a small layerbase OS files: a big layerAn image: sealed files,in stacked layers.A container: one runningcopy of it.Named by hashSame bytes, same 64 digits,so a shared base is kept once.26.47 MB3 images, counted one by one8,822,743 byteson disk: base + 10 + 36Where it stopsThe box holds files only.Kernel: the host's own.The image packs none.Chip: one image per chip.Built for one, the otherrefuses to start it.chalkbrain.com
The shipping container(Docker)Agree on the box, skip the questions.1Image, containeryour code: a small layerbase OS files: a big layerImage: sealed files in layers.Container: one running copy.2Named by hashSame bytes, same hash: a sharedbase is kept once.26.47 MB counted8,822,743 bytes on disk3 images: base + 10 + 363Where it stopsKernel: the host's own.The image packs none.Chip: one image per chip.The wrong one will not start.chalkbrain.com

8 of 8 Keep this

Keep this

An image is an app's files, sealed and stacked in layers. A container is one running copy of it. Each layer is named by the hash of its bytes, so a shared base is kept once, on disk and on the registry.

The price: the box seals files only. The kernel and the chip still belong to the host.

Read the full lesson