Custom Mosquitto Docker image with WebSockets, auto-auth, and unified persistence.
1.9K
Containers built with this Dockerfile compile Mosquitto from source using published tarballs. It is specifically tailored to include WebSockets support via libwebsockets (v5.0.0) and features a unified volume structure with automated credential generation.
9001 alongside the standard MQTT listener on port 1883.MQTT_USER and MQTT_PASSWORD environment variables to automatically generate a secure mosquitto.passwd file on first boot./mosquitto directory.mosquitto user (UID/GID 1883).To spin up the broker with authentication enabled and both ports exposed, run:
docker run -d --name mosquitto \
-p 1883:1883 \
-p 9001:9001 \
-e MQTT_USER=my_user \
-e MQTT_PASSWORD=my_secure_password \
-v mosquitto_data:/mosquitto \
solodolobolo/mosquitto:latest
This will automatically create your credentials, pipe the broker logs directly to the Docker daemon (docker logs mosquitto), and save your persistent data in a Docker named volume.
You only need to mount a single Docker volume:
/mosquittoInside this volume, Mosquitto uses the following subdirectories:
/mosquitto/config (Holds your mosquitto.conf and mosquitto.passwd)/mosquitto/data (Holds your persistent database if persistence true is set)/mosquitto/log (Available if you choose to route logs to a file instead of stdout)A production-ready mosquitto.conf is baked directly into the Docker image. By default, it requires authentication, enables WebSockets, and outputs logs to stdout.
If you are using a Docker named volume (like the Quick Start above), the container will automatically copy the default configuration into your volume the first time it spins up. You can then edit it by executing into the container.
If you prefer to mount a local folder from your host machine, do not mount an empty folder, or Docker will hide the default configuration file and Mosquitto will crash. Instead, extract the default file first:
# 1. Extract the default config from the image to your current local directory
docker run --rm solodolobolo/mosquitto:latest cat /mosquitto/config/mosquitto.conf > ./mosquitto.conf
# 2. Edit your local ./mosquitto.conf file however you like
# 3. Run the container and mount your local file directly over the default one
docker run -d --name mosquitto \
-p 1883:1883 \
-p 9001:9001 \
-e MQTT_USER=my_user \
-e MQTT_PASSWORD=my_secure_password \
-v $(pwd)/mosquitto.conf:/mosquitto/config/mosquitto.conf \
-v mosquitto_data:/mosquitto/data \
solodolobolo/mosquitto:latest
Content type
Image
Digest
sha256:6e43d4fec…
Size
8.5 MB
Last updated
about 1 month ago
docker pull solodolobolo/mosquitto