In Week 12 we learned that Docker packages an app and everything it needs into a container.
docker runThis week we'll use Docker to run a tool called n8n in a single command.
# The Docker idea in one line:
docker run hello-world
# Today we'll do the same thing,
# but run a full automation app:
docker run ... n8n
n8n (pronounced "n-eight-n") is a workflow automation tool.
Think of it as "visual programming" — same logic as Python, but you click instead of type.
A workflow is just nodes joined together.
This is exactly what you'll build in Lab Task 4 — a temperature monitor that alerts Telegram.
A single building block. It does one task (e.g. "make an HTTP request").
The node that starts a workflow — a button click, a schedule, or an event.
The line joining nodes. It carries the data from one node to the next.
The whole picture — all your connected nodes working together.
You only need Docker Desktop installed and running (from Week 12).
If docker --version prints a version number, you're ready.
# Check Docker is installed
docker --version
# e.g. Docker version 27.0.3
# Check the Docker engine is running
docker ps
# Shows an (empty) list of containers
Just like any other image, we pull n8n then run it.
-p 5678:5678 opens the web editor on your machine-v ~/.n8n:/home/node/.n8n saves your work so it survives a restart--name n8n gives the container a friendly nameThe first run downloads the image — give it a minute.
# 1. Download the official n8n image
docker pull docker.n8n.io/n8nio/n8n
# 2. Run it (Windows: use ~/.n8n too in PowerShell)
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
| Flag | What it does |
|---|---|
docker run | Start a new container |
-p 5678:5678 | Connect the container's port to your browser at localhost:5678 |
-v ~/.n8n:/home/node/.n8n | Save workflows on your computer (a "volume") so they are not lost |
--name n8n | Name the container so you can stop/start it easily |
--rm | Clean up the container when you stop it (your saved volume stays) |
Once the terminal shows Editor is now accessible, open your browser:
http://localhost:5678
To stop n8n later: press Ctrl + C in the terminal. Your workflows are saved.
Version: 1.x.x Editor is now accessible via: http://localhost:5678
Open that link in Chrome or Edge.
Golden rule: every workflow must start with a Trigger node.
A node panel looks like this:
GEThttps://...Goal: click a button and produce a small piece of data. The simplest possible workflow.
message Value: Hello from n8n!course Value: CP2// What you'll see in the output panel:
[
{
"message": "Hello from n8n!",
"course": "CP2"
}
]
Goal: pull live data from the internet — the heart of the lab.
We'll use a free joke API so you can see real data instantly.
GEThttps://official-joke-api.appspot.com/random_joke
The API gives back fields like setup and punchline.
// Example response (your joke will differ):
{
"type": "general",
"setup": "Why did the developer go broke?",
"punchline": "Because he used up all his cache.",
"id": 42
}
To use data from an earlier node, n8n uses expressions written in {{ }}.
{{ $json.setup }} → reads the setup field of the incoming item$json always means "the data coming into this node"
In the lab you'll write {{ $json.alert_message }} to put text into the Telegram message.
# Reading fields from the previous node
{{ $json.setup }} → the question
{{ $json.punchline }} → the answer
{{ $json.id }} → the id number
# You can even combine them:
{{ $json.setup }} ... {{ $json.punchline }}
Goal: do something only when a condition is true — exactly like an if in Python.
This is how the lab decides whether a temperature is "out of range".
temperature Value: 120 (type: Number){{ $json.temperature }}100# The IF node is just this in plain English:
if temperature > 100:
go out the TRUE branch # raise an alert
else:
go out the FALSE branch # all good
When a ready-made node isn't enough, the Code node lets you write a little JavaScript.
$input.all() gives you every incoming item{ json: {...} } objectsThe lab uses a Code node to check both sensors and build the alert text.
// Code node: flag temperatures over 100°C
const items = $input.all();
return items.map(item => {
const temp = item.json.temperature;
return {
json: {
temperature: temp,
status: temp > 100 ? 'ALERT' : 'NORMAL'
}
};
});
Your lab combines everything from today into one monitoring workflow:
You now know every block in this chain. The lab just connects them and adds a Telegram bot. Full brief: Task 4 — Industrial Temperature Sensor Monitoring.
Manage your n8n container from the terminal:
Ctrl + C in its terminaldocker ps~/.n8n folderBecause of the volume, your workflows are still there next time you run the container.
# Start n8n again any time
docker run -it --rm --name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
# See what's running
docker ps
{{ $json.x }} reuse it