Troubleshoot a Deployment¶
Diagnose and fix common problems with containerised cosalette applications.
Troubleshooting¶
- Container starts but no MQTT connection
- The broker hostname must be the Compose service name (e.g.,
mosquitto), notlocalhost. Inside a container,localhostrefers to the container itself. Verify name resolution withdocker exec myapp getent hosts mosquitto. - Permission denied on
/dev/ttyUSB0 -
The container needs access to the host device. Options:
- Add
device_cgroup_rules: ['c 188:* rmw']under the service — scopes access to a single device major/minor (preferred). - Map the specific device:
devices: ['/dev/ttyUSB0:/dev/ttyUSB0']. - Add the container user to the
dialoutgroup (group_add: [dialout]).
Do not reach for
privileged: trueto fix a device-permission error: it grants the container full access to every host device and is a trivial container-escape path on a Pi with GPIO/i²c/serial passthrough. The scoped options above are sufficient; never useprivileged: truein production. - Add
- Out of memory on Pi Zero 2 W
-
The Pi Zero 2 W has only 512 MB RAM. To reduce memory usage:
- Set
MYAPP_LOGGING__LEVEL=WARNINGto reduce log buffer pressure. - Use
MemoryStoreorNullStoreinstead ofSqliteStore. - Run
docker system pruneto reclaim space from old images. - Consider adding a swap file on the host.
- Set
- Container restarts in a loop
-
Check the exit code with
docker inspect --format='{{.State.ExitCode}}' myapp:Exit Code Meaning Action 1Configuration error Check env vars — missing required field, invalid value 3Runtime error Check logs with docker logs myappfor the root cause137OOM killed / SIGKILL Increase memory limit or reduce footprint - Image fails to build for arm64
-
Ensure BuildKit and QEMU are set up:
Related guides:
- Containerize Your Application — Dockerfile and multi-arch builds
- Deploy with Docker Compose — Compose configuration, health checks, and persistence
- Harden Your Deployment — security hardening and production logging