MirrorNest
← すべてのガイド

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.

対象: Any Docker hostHome AutomationIoTNetworking公式ホームページ ↗公式ドキュメント ↗
このガイドは上記リンク先にあるMosquitto MQTT broker公式ドキュメントをもとに作成されています。ディストリビューションやプロジェクトのバージョンは時間とともに変わるため、本番サーバーでこれらのコマンドを実行する前に、必ず公式ドキュメントで正確なパッケージ名・バージョン名を確認してください。
  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"