I’m new to Docker, but have been running Grafana and Influxdb in Docker for a few weeks whilst my Homeassistant was running on Hass.io on a Raspberry Pi.
I decided to install Homeassistant (not Hass.io) on Docker and it mostly works except for MQTT, devices that use MQTT do not appear in HA. I’m using configuration.yaml file copied over from my hass.io instance.
I’m assuming it’s either a configuration issue, an MQTT access issue, either communication is not happening due to password or port issues. In Hass.io MQTT just worked with no username and password.
Entry for MQTT in configuration file is:
mqtt:
broker: 127.0.0.1
although I’ve also tried 192.168.2.52 which is the machine’s IP address.
Can anyone tell me how to start troubleshooting this issue please?
Thanks.
I’m trying to use the internal broker but I’ve a strong suspicion that I’m missing a step. I haven’t defined an MQTT password anywhere so I don’t know what password to enter…
or is
I’ve been through the info in the link and adding a password at least makes the relevant switches appear in Homeassistant however the devices are not controllable so I’m guessing they can’t access MQTT. I looked at exposing 1883 but it’s not possible when HA is running on docker in host mode (possibly I’m not using the correct terminology). I’m going to try Eclipse MQTT in Docker and see if that changes anything, I also don’t really want a password as some of my devices will need to be reflashed
I might just have to go back to Hass.io, I like it but as I have a more powerful computer running Docker it was logical to try HA there.
OK I worked around the problem by installing another MQTT broker in Docker:
docker run -ti -p 1883:1883 -p 9001:9001 toke/mosquitto
And changing my configuration.yaml to
mqtt:
broker: 127.0.0.1
Which immediately started working with all my devices without me having to change their configurations (phew!), the only thing I changed was the restart policy to always so it’ll automatically start if the box reboots.
I tried Eclipse but had permission errors, I changed the permissions and then had a message that mqtt.conf was missing, I found an apparent solution on a forum but am too dumb to understand it. It’s odd because all the other Docker stuff just installed without too much fuss.
You are not defining file locations properly(The - v part)
Below mount entire config folder to your server. When first created it will create the config file inside(only when first created and run)
You can modify that file as needed.
It is optional to mount /mosquitto/log and mosquitto/data folder but not bad idea to do so. Just create location on your server and point docker to them similar to /mosquitto/config folder below
docker run -it -p 1883:1883 -p 9001:9001 -v /YourMosqitoConfigFldr:/mosquitto/config eclipse-mosquitto
With increasing amount of docker containers maybe consider using Portainer to manage them as well