Docker / MQTT help required (solved ...sort of)

Tags: #<Tag:0x00007f4801daad40>


I’m new to Docker, but have been running Grafana and Influxdb in Docker for a few weeks whilst my Homeassistant was running on on a Raspberry Pi.

I decided to install Homeassistant (not 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 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 MQTT just worked with no username and password.

Entry for MQTT in configuration file is:


although I’ve also tried which is the machine’s IP address.
Can anyone tell me how to start troubleshooting this issue please?


Get mqtt app on phone or PC
HA config pages that allow send mqtt message.
Send message from ha and see if receive in phone

Are you using ha internal mqtt broker?

Also look here

If using embedded broker should be like

  password: yourpassword



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

  password: yourpassword

where I define my password?


Yes…and if using embedded broker that is all you must define unless you want customize. It is at link provided above

For your docker container you should have 1883 exposed so devices may communicate with HA inside docker container


Hi, thanks for taking the time to help :slight_smile:

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 :frowning:

I might just have to go back to, I like it but as I have a more powerful computer running Docker it was logical to try HA there.


You can run on a NUC as a generic Linux install and then access all the addons…


Yes I think a NUC is on the horizon!


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


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.

Thanks to everyone who took time to help out.


You are probably better off running the official docker image, which is
eclipse-mosquitto. See


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.


When you create the eclipse mosquitto container you need to specify the directories where the config is stored.

the container should create the config files in those directories you specify.


I did this:

docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto


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