A Dreamer's Lair

Run mosquitto in a docker container on the PI

Since I want to migrate all domotica software to my raspberry PI (or perhaps PI’s) it is time to say good bye to my windows mosquitto instance running on my current windows domotica server. Of course I will use docker to run mosquitto also.

I searched the web a bit, and perhaps I didn’t search well enough, but I couldn’t find an up-to-date repository for a mosquitto image that will run on the Raspberry PI. The ones I found, were all a year or more old and for example based on debian jessie whereas debian stretch is the standard now.

So, based on a existing docker file I found on the web, I created a new mosquitto docker image for the Raspberry PI. I have uploaded it to my repository so it can be used by myself, and perhaps others who have looked for one too 🙂

The image can be found here.

As I mentioned in my previous post I already have a mount to my NAS in which I want to store my domoticz data. The mount on the PI is


On this mount I created the necessary sub folders for mosquitto. For mosquitto to work a basic config file should be put in the config folder. As a bare minimum it should have the following contents.

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /mosquitto/data

log_dest file /mosquitto/log/mosquitto.log

The mosquitto image can be installed as follows. I have added the –reatart option so the container is automatically started when for example the PI has been rebooted.

docker run --name=mosquitto \
           --restart unless-stopped \
           -d \
           -e TZ=Europe/Amsterdam \
           -p 1883:1883 \
           -v /home/pi/dockerdata/mosquitto/config:/mosquitto/config \
           -v /home/pi/dockerdata/mosquitto/data:/mosquitto/data \
           -v /home/pi/dockerdata/mosquitto/log:/mosquitto/log \

And behold, mosquitto is running in docker on the PI.

Home Automation

    Your email address will not be published. Required fields are marked *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>