Docker, start to ship · Chapter 26 of 26

Launch day

By the end of this chapter you can take an app from its source to a running stack that comes back by itself, through your own registry, with everything this course taught. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.

  • Part: The launch
  • 5 tasks
  • Docker
  • In the all labs plan

The first 2 chapters of Docker, start to ship are free. This one comes with the all labs plan.

Why you need this

Tapri goes live today. Dev, the CTO, wants to see the orders API (its source is in app/) and the launch page (in site/) shipped properly, and then he will crash the API on purpose to see what happens. Bunty has already "launched":

$ curl -s localhost:8026
Bunty launched it from his laptop

That is chai-26-bunty, a container started by hand that holds the API's port 8026. Nobody can say what code it runs, it runs as root, and if it dies, it stays dead. Each of those problems has a chapter behind it, and today they all come together.

What you build: 5 tasks

Each task has tests. You write the code in the lab's editor and press Check.

  1. Task 1

    Build the release image chai-26-api:1.0

    Build the release image of the orders API.

    1. Write app/Dockerfile for app/server.js. Start from node:24-alpine. The app listens on port 8026.

    2. Make the image run node server.js as an ordinary user, not root.

    3. Add a HEALTHCHECK that asks http://localhost:8026/health from inside the container.

    4. Add the label org.opencontainers.image.version with the value 1.0.

    5. Build it from the app folder as chai-26-api:1.0, then inspect it.

    To pass: chai-26-api:1.0 has a user that is not root and not uid 0, a HEALTHCHECK, and the version label 1.0 (a label called version also counts). The image is 300 MB or smaller.

  2. Task 2

    Ship it through chai-26-registry on 8076

    Ship the release image through Tapri's registry.

    1. Run a container named chai-26-registry from registry:2, in the background, with its port 5000 published on the lab's port 8076.

    2. Give chai-26-api:1.0 a second name: localhost:8076/chai-26-api:1.0.

    3. Push that name, with no TLS.

    4. Run curl localhost:8076/v2/chai-26-api/tags/list.

    To pass: chai-26-registry is running, and localhost:8076/v2/chai-26-api/tags/list has the tag 1.0.

  3. Task 3

    Launch the chai-26 stack, with the api from the registry

    Launch Tapri: the api from the registry, and the menu page.

    1. Delete Bunty's container chai-26-bunty. It uses port 8026.

    2. Write compose.yaml in the chapter folder for a project named chai-26, with two services.

    3. api: the image localhost:8076/chai-26-api:1.0 (no build), network_mode: host, a restart policy (unless-stopped, always or on-failure) and a CPU limit (cpus).

    4. menu: nginx:alpine, network_mode: slirp4netns, the lab's port 8027 published to its port 80, and the site folder mounted read-only at /usr/share/nginx/html.

    5. Bring the stack up in the background. Run curl localhost:8026/health and curl localhost:8027.

    To pass: chai-26-bunty is gone, and both services are running. The api runs exactly localhost:8076/chai-26-api:1.0, with a restart policy and a CPU limit (a memory limit also counts). localhost:8026/health says ok, and the api's healthcheck passes when the Check runs it once. localhost:8027 shows Tapri is live.

  4. Task 4 · interview question

    Interview: survive Dev's crash test

    Interview question: does the api come back by itself after a crash?

    1. Run Dev's crash test: curl localhost:8026/crash. It makes the api exit with code 1.

    2. Wait a second or two.

    3. Inspect the api's container for its restart count and its state. Then run curl localhost:8026/health.

    To pass: you ran curl localhost:8026/crash in the terminal, in the chapter folder. The api container is running again, its RestartCount is more than 0, and localhost:8026/health says ok. Do not make a new api container after the crash: a new container counts from 0.

  5. Task 5 · interview question

    Interview: what an image and a container are

    Interview question: what is an image, what is a container, and how are they related?

    1. Think: what did docker build make, and what did docker run make from it?

    2. Write one or two sentences in your own words in answer.txt, in the chapter folder.

    3. Use both words, image and container.

    To pass: answer.txt uses the words image and container, and says what each one is.

What you will learn

  • A release image: non-root, with a healthcheck and a version label, checked with docker image inspect.
  • Shipping through a registry: the servers run what the registry has, not what someone built on a laptop.
  • A launch stack: compose with a restart policy and a CPU limit, and what a crash looks like when the policy is there.

More in The launch

Build "Launch day" yourself

Tapri’s menu site works on one laptop and nowhere else. You ship the machine. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.

The first 2 chapters of Docker, start to ship are free. This one comes with the all labs plan.