Skip to content
No description or website provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Running Mosquitto with auth in Docker

Simple example of how to run Mosquitto with auth in Docker. I have used the official Eclipse Mosquitto MQTT Broker Docker image.


Place the Mosquitto credentials to the .env file that will be used by the docker-compose.


Build and run

docker-compose build
docker-compose up -d


Try the MQTT client to connect to the Mosquitto MQTT Broker. Use for a local environment.

Or use official mosquitto_pub and mosquitto_sub utilities for publishing and subscribing.

# Subscribe to topic.
mosquitto_sub -h localhost -t test -u "mosquitto" -P "mosquitto"

# Publish a message.
mosquitto_pub -h localhost -t test -m "hello." -u "mosquitto" -P "mosquitto"
You can’t perform that action at this time.