← Todas las guías
Mosquitto MQTT broker
A free, open-source, lightweight MQTT message broker -- the standard messaging backbone connecting smart-home sensors/devices to automation platforms like Home Assistant and Node-RED.
Esta guía se elaboró a partir de la documentación oficial de Mosquitto MQTT broker, enlazada arriba — verifica siempre ahí los nombres exactos de paquetes/versiones antes de ejecutar estos comandos en un servidor de producción, ya que las versiones de la distribución y del proyecto cambian con el tiempo.
1Create a minimal config file
Mosquitto's Docker image refuses external connections with no config by default -- this enables a plain listener for local network use.
mkdir -p mosquitto/configcat > mosquitto/config/mosquitto.conf <<'EOF' listener 1883 allow_anonymous true EOFallow_anonymous true means no username/password is required -- fine for a trusted home LAN, not for anything reachable from the internet. See Mosquitto's docs for password-file-based auth before exposing it externally.
2Run the container
docker run -d \ --name mosquitto \ --restart unless-stopped \ -p 1883:1883 \ -v "$(pwd)/mosquitto/config:/mosquitto/config" \ eclipse-mosquitto3Test it with the mosquitto client tools
The subscriber should print "hello" -- confirms the broker is relaying messages correctly.
mosquitto_sub -h <the-server's-ip> -t test/topic &mosquitto_pub -h <the-server's-ip> -t test/topic -m "hello"