MirrorNest
← Alle Anleitungen

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.

Zielsystem: Any Docker hostHome AutomationIoTNetworkingOffizielle Website ↗Offizielle Dokumentation ↗
Diese Anleitung basiert auf der offiziellen Dokumentation von Mosquitto MQTT broker, oben verlinkt — überprüfe dort immer die genauen Paket-/Versionsnamen, bevor du diese Befehle auf einem Produktionsserver ausführst, da sich Distributions- und Projektversionen mit der Zeit ändern.
  1. 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/config
    cat > mosquitto/config/mosquitto.conf <<'EOF' listener 1883 allow_anonymous true EOF

    allow_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.

  2. 2Run the container

    docker run -d \ --name mosquitto \ --restart unless-stopped \ -p 1883:1883 \ -v "$(pwd)/mosquitto/config:/mosquitto/config" \ eclipse-mosquitto
  3. 3Test 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"