Docker for Edge and IoT
Introduction
Your team has a Raspberry Pi running Mosquitto, Node-RED, and a small database. Installing everything by hand on each board is fragile, versions drift, dependencies conflict, and "it worked on my laptop" returns.
Docker packages an application and its dependencies into an image you run as a container, isolated, repeatable, easy to redeploy. For embedded engineers, Docker is less about the MCU firmware and more about the gateway and cloud edge: the Linux box next to your robots.
Core concepts
| Term | Meaning |
|---|---|
| Image | Read-only template (e.g. eclipse-mosquitto) |
| Container | Running instance of an image |
| Dockerfile | Recipe to build your own image |
| Volume | Persistent data outside container filesystem |
| Port mapping | -p 1883:1883 exposes broker to LAN |
| Docker Compose | YAML file defining multi-container stacks |
In plain terms
An image is a frozen lunch box with exact food inside. A container is when you heat and eat one serving, same recipe every time, no surprise missing salt.
Why embedded/IoT teams use it
| Benefit | Example |
|---|---|
| Reproducible lab | Same Mosquitto + Node-RED stack on every Pi |
| Isolation | Database crash does not kill broker |
| Updates | Pull new image tag; roll back if broken |
| CI/CD | Build gateway services in pipeline |
MCUs still flash firmware normally, Docker runs on Linux gateways (Pi, industrial PC, cloud VM).
Minimal example, MQTT broker
1 | |
Devices on the LAN connect to pi-ip:1883. Config and persistence mount via volumes in real projects.
Docker Compose (sketch):
1 2 3 4 5 6 7 8 9 10 11 | |
Install paths (pick your machine)
| Platform | Notes |
|---|---|
| Raspberry Pi | Docker Engine for ARM |
| Windows / macOS | Docker Desktop for development |
| Linux server | Native engine, common in cloud |
Use official install docs for your OS, versions change; concepts stay the same.
Videos, other ways to learn
Why use Docker
Why Use Docker - Docker Tutorial For Beginners
What is Docker
Docker client basics
What is a container
But Really, What's a Container?
Quick overview
Docker Compose
Relevant topics
Starting points
- Install Docker on your dev machine; run
docker run hello-world. - Start Mosquitto container; connect with
mosquitto_subfrom host. - Write a two-service
docker-compose.ymlfor broker + Node-RED. - Export compose file to Git, teammates reproduce in one command.
Focus points
- Containers are not VMs, they share the host kernel; understand isolation limits.
- Persist data with volumes, container delete should not wipe MQTT config.
- ARM vs x86 images, Pi needs ARM-compatible tags.
- Secrets, use env files or Docker secrets, not hardcoded passwords in Git.