Overview
This template provides a production‑ready Eclipse Mosquitto instance as a Monk runnable. You can:- Run it directly to get a managed MQTT broker with sensible defaults
- Inherit it in your own runnable to seamlessly add MQTT messaging to your IoT infrastructure
What this template manages
- Mosquitto MQTT broker container (
eclipse-mosquittoimage, configurable tag) - Network service on port 1883 (MQTT)
- Network service on port 9001 (WebSocket)
- Persistent volumes for data storage
- Auto-generated configuration file with customizable settings
Quick start (run directly)
- Load templates
- Run Mosquitto with defaults
- Customize configuration (recommended via inheritance)
variables. To customize settings, you can:
- Preferred: inherit and override variables as shown below.
- Alternative: fork/clone and edit the
variablesinmosquitto.yml, thenmonk load MANIFESTand run.
localhost:1883 (or the runnable hostname inside Monk networks) and WebSocket clients to localhost:9001.
Configuration
Key variables you can customize in this template:${monk-volume-path}/mosquitto/data on the host. The configuration file is auto-generated from the template at /mosquitto/config/mosquitto.conf.
Use by inheritance (recommended for apps)
Inherit the Mosquitto runnable in your IoT application and declare a connection. Example:Ports and connectivity
- Service:
mqtton TCP port1883(default) - Service:
websocketon TCP port9001(default) - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the broker host.
Persistence and configuration
- Data path:
${monk-volume-path}/mosquitto/data:/mosquitto/data - Configuration is auto-generated from template variables and mounted at
/mosquitto/config/mosquitto.conf - Supports message persistence, retained messages, and persistent sessions
Features
- MQTT v3.1, v3.1.1, and v5.0 support
- QoS levels 0, 1, and 2
- Retained messages
- Last Will and Testament
- WebSocket support for browser-based clients
- Message persistence
- Configurable connection limits
- Flexible logging
Related templates
- Use with microservices for async communication
- Combine with stream processing (Kafka Streams, Flink)
- Integrate with monitoring (
prometheus-grafana/) - Pair with Node-RED for IoT workflow automation
Troubleshooting
- If you changed
allow-anonymoustofalse, ensure you have configured authentication (password file or auth plugin) in a custom configuration. - Ensure the host volumes are writable by the container user.
- For production use, consider setting
allow-anonymous: falseand configuring proper authentication. - Check logs: