Heidelberg AICurriculum
Track 12 · Advanced
12.6

Deploy & Run Applications with Docker

Containers, images, and volumes — the mental model behind every local AI tool you install

5 lessons 2026-08-06 AI-generated

1Overview

Docker is the standard way to package software with everything it needs to run — the right language version, libraries and system packages — into a single image. Run that image and you get a container: an isolated, disposable process that behaves the same on any machine and starts in about a second, not the minute-plus a VM needs. Anything you can't afford to lose on a restart goes in a volume instead, kept separate from the throwaway container. That is the whole model — image, container, volume — and it is the one nearly every local AI tool here (Ollama, Open WebUI, n8n, vLLM) assumes you already have, which is why their install docs jump straight to a compose file instead of a manual setup guide.

Every install chapter in this course — and half the tools in it — assumes you already know what a container is. This chapter is the missing piece: what an image, a container, and a volume actually are, why "it works on my machine" stops being a problem once you use them, and why Ollama, n8n, Open WebUI, AnythingLLM, and Open Notebook all ship as a docker-compose.yml instead of a manual install guide. It also tells you honestly when you do NOT need Docker. No install steps here — those live in the Windows, macOS, and Linux chapters this one hands you off to.

1.2After this chapter you can
Explain what a container is — and why it starts in a second, not the minute-plus a VM needs to boot
Tell an image, a container, and a volume apart, and know which one your data actually lives in
Understand why pinning a version inside an image kills the "works on my machine" bug class
Recognise when Docker is worth the overhead — and when a plain script or native app is the better call
1.3Best for

Anyone about to install Docker who wants the mental model FIRST — so the install chapter's steps make sense instead of being copy-paste magic.

1.4Watch out

This chapter has no install steps — it is deliberately OS-agnostic. Once you're convinced you need Docker, go install it via the Windows, macOS, or Linux chapter.

1.5When you don't need it

A single script you run yourself, or a native desktop app that already bundles its dependencies (e.g. LM Studio) — Docker earns its overhead only when there is a real dependency or reproducibility problem to solve.

2Sub-chapters

3In depth

What a container actually is, before you install one. Docker packages an app with everything it needs into an image; running that image gives you a container; a volume is where the data that must survive a restart lives. This is the mental model every local AI tool in this curriculum — and every OS install chapter below — assumes you already have.

4Lessons 5

4.1 Run a Docker container and watch it finish

A container is an isolated process that shares the host’s kernel but runs with its own filesystem and network stack, giving it the feel of a separate lightweight machine.

Start a container that prints a message and exits instantly

Trydocker run hello-world

No Docker installed yet? Use https://labs.play-with-docker.com for a free, zero-install browser sandbox — same commands, no local setup. Otherwise this works once you've installed Docker for your OS (see the Windows / macOS / Linux chapters).

  1. OPEN terminal and type docker run hello-world
  2. WAIT for Docker to pull the hello‑world image if it is not already present locally
  3. OBSERVE Docker CREATE a container from that image and RUN it
  4. NOTE that the container prints its message and then EXITs automatically
  • You'll see 'Hello from Docker!' appears in the terminal within a second or two, with no boot screen
  • Takeaway Containers are isolated processes that share the host kernel, so they start as fast as any regular program
  • Check If a container shares the host's kernel, what's actually different between a container and a normal program you'd just run directly?

4.2 Run two independent containers from one image and observe data loss without a volume

An image is a read‑only blueprint; a container is a running (or stopped) instance of that blueprint; a volume provides persistent storage that outlives the container’s disposable filesystem.

Do this first Run a Docker container and watch it finish

Create two separate containers from the same PostgreSQL image, delete one, and see that its file disappears because it was not stored in a volume

Trydocker images && docker ps -a && docker volume ls

Three commands, three layers of the model.

  1. LIST downloaded images with docker images to confirm the postgres:16 blueprint exists
  2. START the first container using docker run -d --name box1 -e POSTGRES_PASSWORD=secret postgres:16
  3. START the second container using docker run -d --name box2 -e POSTGRES_PASSWORD=secret postgres:16
  4. SHOW both containers with docker ps -a, verifying they were created from the same image
  5. CREATE a file inside box1 via docker exec box1 sh -c "echo test > /tmp/note.txt"
  6. REMOVE box1 with docker rm -f box1 and note that /tmp/note.txt is no longer present
  7. LIST existing volumes using docker volume ls, highlighting that no volume was used for the file
  • You'll see Both box1 and box2 appear in docker ps -a, then the file you created inside box1 is gone after removing the container
  • Takeaway Containers share an image but have isolated writable layers, so data persists only when placed in a Docker volume
  • Check You just deleted a database container that had no volume attached. What actually happened to the data — and how would a volume have changed the outcome?

4.3 Verify a Docker stack is reproducible

A Dockerfile defines an exact base OS, runtime, dependencies and startup command; building it creates an immutable image that runs identically on any machine.

Do this first Run two independent containers from one image and observe data loss without a volume

Confirm that a docker‑compose file pins exact images and that those images guarantee identical environments across machines

Trydocker inspect postgres:16 --format "{{.Id}}"

Prints a content hash — proof the image is a fixed, addressable artifact, not a version number someone could silently republish differently.

  1. OPEN the official docker‑compose.yml for n8n at its documentation site
  2. OBSERVE that the file specifies exact tags for both the n8n and Postgres images
  3. RUN docker inspect postgres:16 --format "{{.Id}}" in a terminal and note the hash displayed
  4. COMPARE the printed ID with any other machine’s output to see they match exactly
  • You'll see docker inspect prints a fixed image ID, proving the artefact does not change
  • Takeaway Pinning images removes reliance on each developer’s local versions so the same stack runs everywhere
  • Check Two people both run pip install from the same requirements.txt six months apart. Why might they get different environments — and why would the same Dockerfile always give them the same one?

4.4 Identify the role of each service in a docker‑compose file

Ollama, n8n, Open WebUI, AnythingLLM, Open Notebook — nearly every tool in this curriculum's local-and-private track ships a docker-compose.yml. That's not a coincidence: these tools bundle a specific Python or Node version, specific ML libraries, and sometimes a specific database (SurrealDB, Postgres) — exactly the kind of dependency tangle Docker exists to solve.

Do this first Verify a Docker stack is reproducible

Name the purpose of every service defined in example docker‑compose.yml files

Trydocker compose config

Run inside any tool's folder that has a docker-compose.yml — prints the fully-resolved stack Docker is about to create, service by service.

  1. Open Terminal and navigate to the folder containing the example docker‑compose.yml
  2. Run docker compose config to display the resolved configuration for all services
  3. Read each service block in the output and note its image, exposed ports and mounted volumes
  4. Compare the listed services with the description of the tool (e.g., app service, database service) and state what each one provides
  • You'll see docker compose config lists each service with its image, ports and volumes, showing the complete stack on one screen
  • Takeaway Docker lets maintainers resolve complex dependencies once at build time so you only need a single command to run a fully configured environment
  • Check Name one dependency problem Ollama's single-container setup avoids that you'd otherwise have to solve by hand.

4.5 Choose when to avoid Docker

Docker adds overhead only when there is a real dependency or reproducibility problem to solve; otherwise it is unnecessary extra complexity.

Do this first Identify the role of each service in a docker‑compose file

Decide, for a few concrete situations, whether Docker is actually worth reaching for.

Trydocker-intro assess-need .

Paste the command into the Terminal screen of the docker‑intro tool and press Enter. Watch the summary it prints – it will list each scenario and say YES if Docker is recommended or NO otherwise.

  1. SKIP Docker for a single Python script you run yourself
  2. SKIP Docker for a polished single‑purpose desktop app that already handles its own dependencies
  3. USE Docker when a tool requires a specific database, runtime and configuration to work together
  4. USE Docker when you need the same environment on multiple machines
  5. USE Docker when you want to run several versions of the same service side by side
  • You'll see A clear yes/no for each situation above, and a next step: your OS's Docker install chapter
  • Takeaway Docker solves one specific problem — dependency reproducibility across environments and machines; if that problem doesn't exist yet, the overhead isn't worth it
  • Check Your lab has one shared GPU server that five people SSH into to run different Python projects with conflicting dependency versions. Is this a "reach for Docker" situation? Why?

5You’ll know it worked 5 checkable outcomes in this chapter

  • The process ends with Docker reporting `Exited (0) ...` shortly after start
  • `Hello from Docker!` appears within a second or two of running the command
  • `docker ps -a` shows both `box1` and `box2` listed as separate containers built from `postgres:16`
  • `docker ps -a` no longer lists `box2`
  • The command prints a long hexadecimal string (the image ID) that stays constant for that image tag

6FAQ, Tips & How-to 19

one problem, one solution, one action
How-to Everyone

Docker will fetch an image from Docker Hub if it is not already cached locally, ensuring the command always has what it needs

Lesson → AI-generated
How-to Everyone

Want a process to see only its own files

Docker turns an image into a runnable container, giving the process its own isolated view of files

Lesson → AI-generated
How-to Everyone

A container executes the command defined in its image and stops automatically when that command finishes

Lesson → AI-generated
Tip Everyone

Isolation without second kernel — why containers are lighter

Containers achieve process isolation using namespaces and cgroups, avoiding the overhead of a full guest operating system

Lesson → AI-generated
How-to Everyone

Seeing `Hello from Docker!` confirms that the container ran successfully and demonstrates Docker's fast start-up

~5 min · no code Lesson → AI-generated
How-to Everyone

An image is a static, immutable template you build once and reuse for any number of containers

Lesson → AI-generated
How-to Everyone

A container is a running (or stopped) instance of an image with its own isolated, writable layer that disappears when the container is removed

Lesson → AI-generated
How-to Everyone

Want two separate instances from the same image

You can start multiple containers from the same image; each gets its own isolated filesystem

Lesson → AI-generated
How-to Everyone

Container still shows up in list

Removing a container frees resources and ensures no leftover state interferes with later experiments

Lesson → AI-generated
How-to Everyone

Running the combined commands lets you verify images, containers, and volumes are present as expected

~5 min · no code Lesson → AI-generated
Tip Everyone

A Dockerfile captures the exact OS, runtime version, dependencies, and startup command so the resulting image runs identically everywhere

Lesson → AI-generated
How-to Everyone

Need exact image tags in compose files

Specifying exact image tags in a docker-compose file locks the whole stack to known versions, preventing "works on my machine" bugs

Lesson → AI-generated
How-to Everyone

`docker inspect` reveals the immutable image ID hash, proving that you are using a fixed binary rather than a moving target

~5 min · no code Lesson → AI-generated
FAQ Everyone

What exactly is a Docker container?

A Docker container is an isolated process that runs like a regular program but has its own filesystem and network view, while sharing the host’s Linux kernel. This isolation gives fast startup and low overhead compared to a full virtual machine.

AI-generated
FAQ Everyone

What happens if I run a container image that isn’t on my computer?

Docker first checks for a local copy of the requested image; if it’s missing, Docker automatically downloads (pulls) it from Docker Hub or another registry before starting the container. This ensures the command always has what it needs.

AI-generated
FAQ Everyone

How can I verify that a container started correctly?

Running `docker run hello-world` prints “Hello from Docker!” and then exits; seeing this output confirms the container launched successfully and demonstrates Docker’s quick start‑up time.

AI-generated
FAQ Everyone

What is the difference between an image and a container?

An image is a read‑only snapshot of a filesystem that contains everything needed to run an application. When you start a container, Docker adds a writable layer on top of that image, creating a temporary runtime instance.

AI-generated
FAQ Everyone

Can I run multiple containers from the same image?

Yes, each time you start a container from an image it gets its own isolated filesystem and resources, so you can have several independent instances running side by side.

AI-generated
FAQ Everyone

How do I remove a container that I no longer need?

Use `docker rm -f <container-name>` to force‑remove the container; this deletes its writable layer and frees the resources, ensuring it no longer appears in `docker ps`.

AI-generated

The same set on /recipes, filtered by tool and role.

7Videos 2

8FAQ 6

What exactly is a Docker container?

A Docker container is an isolated process that runs like a regular program but has its own filesystem and network view, while sharing the host’s Linux kernel. This isolation gives fast startup and low overhead compared to a full virtual machine.

What happens if I run a container image that isn’t on my computer?

Docker first checks for a local copy of the requested image; if it’s missing, Docker automatically downloads (pulls) it from Docker Hub or another registry before starting the container. This ensures the command always has what it needs.

How can I verify that a container started correctly?

Running `docker run hello-world` prints “Hello from Docker!” and then exits; seeing this output confirms the container launched successfully and demonstrates Docker’s quick start‑up time.

What is the difference between an image and a container?

An image is a read‑only snapshot of a filesystem that contains everything needed to run an application. When you start a container, Docker adds a writable layer on top of that image, creating a temporary runtime instance.

Can I run multiple containers from the same image?

Yes, each time you start a container from an image it gets its own isolated filesystem and resources, so you can have several independent instances running side by side.

How do I remove a container that I no longer need?

Use `docker rm -f <container-name>` to force‑remove the container; this deletes its writable layer and frees the resources, ensuring it no longer appears in `docker ps`.

9Glossary 12 terms

Show the 12 terms
Docker
Container
An isolated process that has its own filesystem and network view but shares the host’s Linux kernel.
Image
A read‑only snapshot of a filesystem that contains everything needed to run an application.
Namespace
A Linux feature that gives a container its own separate view of system resources like processes and networking.
Cgroups
Linux controls that limit and account for the CPU, memory, and other resources used by a container.
Immutable image ID hash
A fixed identifier shown by docker inspect that proves you are using exactly the same image binary each time.
docker run
Command that creates a container from an image and starts it, optionally running a specific command inside.
docker images
Command that lists all image snapshots stored locally on your machine.
docker ps
Command that shows the containers currently existing (running or stopped) on the host.
docker rm
Command that deletes a container, freeing its resources and removing it from the list shown by docker ps.
docker inspect
Command that displays detailed metadata about an image or container, such as its ID hash.
Dockerfile
A plain‑text file that contains step‑by‑step instructions for building a Docker image.
docker-compose.yml
A YAML configuration file that defines multiple services, their images, and how they should be started together.

10See also

💬 Discuss this chapter

Ask, share, or report — over on the Heidelberg AI community forum.