Containers

Play this lesson

It works on my laptop

Shard Garden's race server works on Remy's laptop. On a production server, with a different version of Node and its libraries, it crashes.

A container packs the program with everything it needs, so it runs the same everywhere.

An image and a container

Docker's guide defines a container image as "a standardized package that includes all of the files, binaries, libraries, and configurations" a program needs. "Images are immutable": once made, they "can't be modified."

A container is what runs from an image: "an isolated process with all of the files it needs to run."

Quick check

Remy packages the race server. Which one can never be changed once it is made?

  1. The image
  2. The container
  3. Both change all the time
Show the answer

The image

Images are immutable. A change means building a new image, which gets a new version.

Four promises

Docker lists what a container gives:

Read the Dockerfile

Dockerfile
FROM node:22-slimWORKDIR /appCOPY package*.json ./RUN npm ciCOPY . .CMD ["node", "server.js"]

Which line starts the race server when a container runs?

  1. CMD ["node", "server.js"]
  2. RUN npm ci
  3. FROM node:22-slim
Show the answer

CMD ["node", "server.js"]

FROM picks a base image. RUN "actually runs a command" while the image is built, here installing packages. CMD runs nothing at build time: it sets the command a container starts with.

Not a whole computer

A virtual machine is "an entire operating system with its own kernel, hardware drivers, programs, and applications."

A container is just a process. Many containers "all share the same kernel", the core of the host's operating system, so they start in moments and one server can run many.

Quick check

Why can one server run many more containers than virtual machines?

  1. Containers share the host's kernel instead of each running a whole operating system
  2. Containers have no files
  3. Virtual machines cannot run games
Show the answer

Containers share the host's kernel instead of each running a whole operating system

Each virtual machine carries a full operating system. Containers share one, so each is much lighter.

One image, every environment

The pipeline builds the race server's image once and tags it, for example race:2.14.0. Staging runs that image. When staging passes, production runs the very same image.

Quick check

After staging passes, the pipeline should build a fresh image for production.

Show the answer

False

A fresh build could pick up different library versions. Production runs the exact image staging tested.

To every player at once?

The image is tested. Sending it to every player at the same moment is still a risk.

Bolt says: Next: canary releases.

Fact-checked 12 October 2026