Mosquitto Broker in Docker !!!

preview_player
Показать описание
If you like what you see..... buy me a coffee!

This video is a tutorial on how to install mosquitto mqtt broker in docker!

Here are a few links to get you started....

(0:00) Intro

(1:56) Start by creating local volume on the docker host..

mkdir mosquitto

(2:33) Now we are ready to install mosquitto in a docker container.

mqtt:
container_name: mqtt
image: eclipse-mosquitto
restart: always
volumes:
- /home/adrian/mosquitto/config: /mosquitto/config
- /home/adrian/mosquitto/data: /mosquitto/data
- /home/adrian/mosquitto/log: /mosquitto/log
ports:
- 1883:1883
- 9001:9001

Onces thats done, save the file and...

sudo docker-compose up -d

Now we are ready to get the config file from eclipse-mosquitto repo...

cd eclipse-mosquitto

Once all that is done, jump over to portainer and reboot the mqtt container.

(6:22) Now we are ready to create a username and password for mosquitto.

sudo docker exec -it mqtt sh
mosquitto_passwd -c /mosquitto/config/pwfile hass

password_file /mosquitto/config/pwfile

Save it and then jump over to restart the mqtt container for the changes to take.

Thats pretty much it.

If you like the video, please subscribe to my channel. If you have any questions or comments, hit me up in the comments below. As always, if there are any videos out there you would like to see, let me know in the comments as well and I will see what i can do.
Рекомендации по теме
Комментарии
Автор

At first I wanted to install mosquitto via IOTStack, but with this tutorial I learned all the necessary steps myself. Thank you very much.

MrEXXS
Автор

Kept getting a "Error: Address not available" in my mqtt container log. Turns out that this error is related to some change in loopback interface in mqtt V2.0. To fix it you need to add "listener 1883" to your mosquitto.conf file.
Figured I'd post this for anyone having this newer issue when doing this tutorial.
Thanks again though! Works beautifully.

donankeny
Автор

I couldn't have set up MQTT on my NUC without your video! BurnsHA = HA Docker Champ!!!

pashadavidson
Автор

If you're looking for more content request, an update to this video to have mqtt use a Let's Encrypt SSL certificate would probably be helpful to a lot of people.

BradleyHerbst
Автор

Hey, thank you! Was trying to run it straight from a container but I couldn't get it to use a port. You helped a lot!

SkyeBuddy
Автор

I had issuee connecting. In the end I had to add "listener 1883" and "allow_anonymous false" to the config. Now it works.

Aetohatir
Автор

You have a typo in the git clone command in your description. A, instead of a .

Aetohatir
Автор

thanks, used for my iotstack, right to the point, thanks

albertroswell
Автор

Great tutorial. Only one problem for me. It keeps saying Client *** disconnected, not authorized. in the mqtt portainer log. My client is a tasmota device.

logane
Автор

I came here as I'm interested in running my MQTT broker outside home assistant. I have a production and a developer Home Assistant instance and this makes it harder to run the MQTT broker in Home Assistant as I have to change say the Node-RED setup from one MQTT broker to another. So running the MQTT broker on it's on Linux (Fedora 36) instance seems a nice alternative. I see you're using Portainer in your video. Can I use the Home Assistant add-on even though this MQTT broker runs on another Linux server?

meierthomas
Автор

I'm really struggling and I'm not sure why... I have docker running, and other images running ok, this is alluding me! My mqtt container won't start properly, it is constantly re-starting. I have tried doing it through docker-compose and have the same result as doing it manually. I reloaded my centos7 from scratch this morning hoping that would help, but it hasn't. I'm at a bit of a loss. the data, config and log folders were created automatically within my "mosquitto" folder in my home directory. I have run "chmod -R 777" on the mosquitto folder incase it was a permissions thing, but that doesn't seem to have helped either... Any ideas?

simonhoy
Автор

Followed instructions, great. However it keeps trying to run as user 1883 and I get no log output in Portainer.
Can see the log in mosquitto.log though

seanmccabenz
Автор

Nice Content. Is it possible to have a bridge cloud mqtt broker as well while running in docker

diontristenaguilar
Автор

I find errors on the code of the description: after "config: data: log: " remove the space, and the github clone line, replace the comma for a dot

jonatanpn
Автор

hey, thanks for the tutorial. I have sent accidently some retained flagged messages which I want to delete now. So how can I use things like
sudo systemctl stop mosquitto.service
?
I want to delete unwanted retained mqtt messages like in this example:
I don't know how to do that inside docker :(

tromtrom
Автор

- /home/adrian/mosquitto/data: /mosquitto/data please loose the space after :
this happens frequently here. any way you rock.

hamhumtube
Автор

Hi thanks for the video! want to ask you from where can I open this file docker-compose.yaml could not find it !!

lamaa
Автор

this is great - I am trying to deploy it on Google Run (Google Cloud) but having all sorts of issues. Would be great if you (or someone else) who has the skills can show how to do this ?

warperone
Автор

if you search for mosquitto on the hub, there are other containers, too, which add this and that, same for other projects... do you suggest to stick with the official ones, always? thanks

squalazzo
Автор

Hm. Not very clear if one does not use Home Assistant.

ojuleko