How to install Mosquitto broker using docker

For Z-Wave related questions in Domoticz

Moderator: leecollings

Post Reply
fillister
Posts: 12
Joined: Thursday 15 July 2021 2:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to install Mosquitto broker using docker

Post by fillister »

Hello all,

I recently reinstalled Domoticz on my raspberry pi and am now using the below listed version:

Version: 2022.1
Build Hash: c9526851b
Compile Date: 2022-01-31 01:34:32
dzVents Version: 3.1.8
Python Version: 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]

My previous install of Domoticz was running zwave with OWZ and a Aeotec Z stick gen 5,while it worked to my sanctification it appears as though the MQTT version is now the preferred way to go. I've successfully installed Docker and Docker composer and would like to install mosquitto broker utilizing Docker as recommended. My problem is that I cannot seem to find step by step instructions on how to perform this install, I would be grateful if someone could direct me to a site that has this information or could post the steps so that I may successfully complete this part of the install.

Thank you

Greg T
User avatar
waltervl
Posts: 5904
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to install Mosquitto broker using docker

Post by waltervl »

I am wondering this too. For some people Docker is the holy grail for all issues ;-)
But when someone can answer this question I can update the wiki with proper instructions.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Tomotics
Posts: 1
Joined: Monday 06 November 2023 15:53
Target OS: -
Domoticz version:
Location: France
Contact:

Re: How to install Mosquitto broker using docker

Post by Tomotics »

But when someone can answer this question I can update the wiki with proper instructions.
Hello @fillister !
Docker is not the Holy Grail for me,
and even less for home automation (ressources consuming, not as fast as OS binaries, ...) but for a specific testing I configured Domoticz with Mosquitto on Docker :D
First, I prefer to make a docker-compose .yml file with all the Docker configuration instead of typing 2km long commands, in the folder with my docker-compose .yml file, just a

Code: Select all

docker-compose up -d
is necessary to run everything.

For running Domoticz on Docker I used the docker-compose .yml file sample specified in the official Domoticz docker hub repository:
https://hub. docker .com/r/domoticz/domoticz

Then I added at the end of this file the following configuration:

Code: Select all

  mosquitto:
        image: eclipse-mosquitto:2
        ports:
            - 1883:1883
            - 9001:9001
        volumes:
            - ./mosquitto/config:/mosquitto/config
            - ./mosquitto/data:/mosquitto/data
            - ./mosquitto/log:/mosquitto/log
  • It uses the official eclipse-mosquitto v2 docker image
  • We need to exposes the ports 1883 and 9001 else our home smarts devices will not be able to connect to the broker
  • Config, data and logs folders will be written on the host (else you will loose your data when Docker stops)
  • We also need to mount a mosquitto .conf file for setuping some configuration:
On your host at the same place of your docker-compose .yml file create the file
  • ./mosquitto/config/mosquitto .conf:

Code: Select all

allow_anonymous true
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto .log
listener 1883
  • allow_anonymous true: On my sample configuration I didn't use credentials
  • persistence true: Mosquitto will write messages on the hard drive (safer in case Mosquitto restarts and some have not been processed)
  • listener 1883: I couldn't access my Mosquitto broker without this directive
Then start your docker with

Code: Select all

docker-compose up
(or with -d option for running in background)

Now your Mosquitto broker address is the address (or IP) of you host machine.

:!: Be careful I had to add spaces on URL and file names to make the post valid:
  • docker-compose .yml
  • mosquitto .conf
  • mosquitto .log
lost
Posts: 662
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to install Mosquitto broker using docker

Post by lost »

Tomotics wrote: Monday 06 November 2023 17:42 Docker is not the Holy Grail for me,
and even less for home automation...
Well, there's a xkcd for that!
https://xkcd.com/1988/

From the hell of (mostly avoidable) dependencies planet alignment to the container glue making them sleep side by side (instead of together!)...
:lol: :o
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest