Mosquitto is a simple MQTT message broker.
It is easiest to install via docker compose:
services:
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto
restart: unless-stopped
volumes:
- ./data:/mosquitto/data
- ./config:/mosquitto/config
- ./log:/mosquitto/log
ports:
- 1883:1883/tcp
- 1883:1883/udp
- 9001:9001Adding a user
Adding a user should be done through the container’s shell. Once there (sh, not bash):
$ cd /mosquitto/config
$ mosquitto_passwd mosquitto.passwd {username}
Avoid common mistake
Do NOT use the
-cflag withmosquitto_passwd! This wipes existing entries in the password file (it’s the “create new file” button).