SECTION 02 · 10 MIN READ & EXPLORE
Give an idea somewhere to run
Turn an explanation into an experiment with steps, source files, predictions, and observable results.
DEMONSTRATION CONTENTA lesson starts with a question and gives the learner a way to investigate it. The components below keep that investigation together. Commands run in the learner’s terminal; the website does not execute them.
Start with a problem
Make a tiny Compose experiment
You want a repeatable way to run a command without installing its runtime on your laptop. Can a small Compose file describe the experiment?
Before you start
- Docker with Compose installed and running.
- An empty working directory and a terminal.
Your mission
- Inspect the configuration before running it.
- Run the container and compare its output with your prediction.
- Change one value and explain the result.
Experiment files
compose.yaml
services:
hello:
image: alpine:3.22
command: ["echo", "Hello, curious engineer."]verify.sh
#!/bin/sh
set -eu
output=$(docker compose run --rm hello)
printf '%s\n' "$output"
printf '%s\n' "$output" | grep -Fx 'Hello, curious engineer.'
echo 'Verified: the container printed the expected message.'What will this container do?
Read compose.yaml. What will appear in your terminal, and will the container keep running afterward?
Try your own explanation first. These notes stay on this page and are not saved or graded.
Show explanation
The container runs the command in the Compose file, prints Hello, curious engineer., and exits when that command finishes. A container can do a short task; it does not have to be a long-running server.
Run, observe, change
Save the configuration
Host terminalDownload
compose.yamlinto an empty directory. Check that Compose can read it:docker compose configExpected observation
Compose prints the resolved configuration. It has one service named
hello.Run the experiment
Host terminaldocker compose run --rm helloThe command failed. What should I check?
Confirm Docker is running, that
docker compose versionworks, and that your current directory containscompose.yaml. Read the error before changing the configuration.Expected observation
You see
Hello, curious engineer.. The command returns to your shell. The first run may also print image download progress.Change one thing
Text editor, then host terminalReplace the message in
commandwith your own. Predict the new output, then run the same command again.Show an example change
Change the command to
echo Hello from my experiment.. Rundocker compose run --rm helloagain. The container should printHello from my experiment..Expected observation
The output matches your new message. Explain which setting changed and which settings stayed the same.
How to know it worked
- The container prints the message from the Compose file and exits.
- Changing the command changes the output on the next run.
Before editing the original message, you can download verify.sh from its file tab and run sh verify.sh in the same directory. It checks the original output. After changing the message, explain why that check fails and update the check to match your intended result.
Leave the environment clean
docker compose downThis removes the experiment’s Compose network if one was created.
Use callouts for consequential details
Authoring reference
Files from the lab itself
<CodeFiles title="Application files" files={[
{ src: "/labs/hello/compose.yaml" },
{ src: "/labs/hello/verify.sh", lang: "bash" }
]} />
Files are read at build time from public/labs/. Tabs support arrow keys, Home, and End. All files remain readable without JavaScript and when printing. A single file has no tab controls. Use name to override a displayed filename, or provide { name: "example.sh", code: "echo hello", lang: "bash" } for a short inline example.
A step with an observation and a hint
<Steps title="Inspect the service">
<Step title="Send a request" location="Host terminal">
Run `curl http://localhost:8080`.
<div slot="expected">
The response contains your application’s greeting.
</div>
<Reveal title="Connection refused?">
Check whether the service is running and which port it publishes.
</Reveal>
</Step>
</Steps>
Steps stay visible together. Use location to distinguish host, container, and remote-server commands.
A prediction with an explanation
<Checkpoint title="Will the data survive?">
What happens if you replace the container but keep its named volume?
<div slot="explanation">
The replacement container can mount the existing volume and read its data.
</div>
</Checkpoint>
The response field is optional for the learner. Notes are not stored or graded, and the explanation can be opened whenever needed. Reveal also accepts kind="hint", kind="solution", or kind="explanation", plus open to start expanded.
A lab with clear boundaries
<Lab
title="Restore a missing player"
scenario="A recent commit removed a player from the squad."
prerequisites={["Git installed", "The prepared exercise repository"]}
objectives={["Find the relevant commit", "Restore only the affected file"]}
success={["The player is present again", "The recovery is committed"]}
>
Add Markdown, Steps, Checkpoints, and CodeFiles here.
<div slot="cleanup">
Explain how to leave the exercise environment clean.
</div>
</Lab>
Lab also accepts a verification slot for commands or evidence beyond the success list. All the original Lab properties and plain Markdown content continue to work.
Take a moment to explain the idea in your own words.