Mosquitto Broker in Docker !!!

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 มิ.ย. 2024
  • If you like what you see..... buy me a coffee!
    www.buymeacoffee.com/c1THy8VNA
    This video is a tutorial on how to install mosquitto mqtt broker in docker!
    Here are a few links to get you started....
    hub.docker.com/_/eclipse-mosq...
    github.com/eclipse/mosquitto
    (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.
    sudo vi docker-compose.yaml
    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...
    sudo git clone github.com/eclipse/mosquitto,git eclipse-mosquitto
    cd eclipse-mosquitto
    sudo mv mosquitto.conf ../mosquitto/config
    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
    (7:36) Lastly, we need to edit mosquitto.conf
    sudo vi mosquitto.conf
    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.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 68

  • @MrEXXS
    @MrEXXS 2 ปีที่แล้ว +3

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

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว +1

      Great to hear!

  • @donankeny5013
    @donankeny5013 2 ปีที่แล้ว +2

    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.

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว

      Yes thank you for the comment. I have had this on my list to create a new video since they updated mosquitto for that exact reason.

    • @jorunessa
      @jorunessa ปีที่แล้ว

      The same problem here!

  • @pashadavidson6808
    @pashadavidson6808 3 ปีที่แล้ว

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

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      Thank you for the comment, and thanks for the coffee as well, much appreciated!!

  • @SkyeBuddy1
    @SkyeBuddy1 3 ปีที่แล้ว

    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!

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      awesome, glad to hear it!

    • @armandonicolas2651
      @armandonicolas2651 3 ปีที่แล้ว

      pro tip : watch series on flixzone. I've been using them for watching all kinds of movies these days.

    • @albertolucca8187
      @albertolucca8187 3 ปีที่แล้ว

      @Armando Nicolas definitely, been using Flixzone for since november myself :D

  • @crc-error-7968
    @crc-error-7968 2 ปีที่แล้ว

    Thank you for the helpful content!

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว +1

      Glad it was helpful!

  • @patrickkonasugawa3663
    @patrickkonasugawa3663 2 ปีที่แล้ว

    Thank you!

  • @albertroswell
    @albertroswell 2 ปีที่แล้ว

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

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว

      Glad it helped!

  • @BradleyHerbst
    @BradleyHerbst 3 ปีที่แล้ว +3

    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.

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว +2

      ill add it to the list, thanks for the comment!

  • @meierthomas
    @meierthomas 2 ปีที่แล้ว

    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?

    • @sarac.1069
      @sarac.1069 7 หลายเดือนก่อน

      Did you manage to solve this? I think I have a similar problem

    • @meierthomas
      @meierthomas 7 หลายเดือนก่อน

      @@sarac.1069 Yes, I ended up spinning another Linux VM (KVM) for MQTT. This VM runs MQTT as Docker container. Now I can manage HA and MQTT separately

  • @diontristenaguilar3924
    @diontristenaguilar3924 2 ปีที่แล้ว

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

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว

      ill have to do some checking, I havent seen anything like that.

  • @warperone
    @warperone 3 ปีที่แล้ว

    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 ?

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      ill see what I can find out.

  • @ronm6585
    @ronm6585 4 ปีที่แล้ว

    Thanks.

    • @BurnsHA
      @BurnsHA  4 ปีที่แล้ว

      thanks for the comment!

  • @squalazzo
    @squalazzo 4 ปีที่แล้ว

    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

    • @BurnsHA
      @BurnsHA  4 ปีที่แล้ว +1

      it just depends. If you see another one that has feature you are interested in, give it a shot. The main thing to check, is to make sure that it is kept up to date.

  • @simonhoy6158
    @simonhoy6158 3 ปีที่แล้ว

    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?

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      are you seeing anything in the logs for the mqtt docker container that might help?

  • @logane3679
    @logane3679 2 ปีที่แล้ว

    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.

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว

      did you make sure the broker username and password were set correctly. thats the only thing I can think of that would be causing that error.

  • @jonatanpn
    @jonatanpn 3 ปีที่แล้ว

    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

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว +1

      thanks for the comment

  • @seanmccabenz
    @seanmccabenz 3 ปีที่แล้ว

    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

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      can you show me your config?

    • @seanmccabenz
      @seanmccabenz 3 ปีที่แล้ว

      @@BurnsHA pastebin gACZGG4e Thanks

  • @tromtrom009
    @tromtrom009 3 ปีที่แล้ว

    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:
    community.openhab.org/t/clearing-mqtt-retained-messages/58221
    I don't know how to do that inside docker :(

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      have you checked in the mosquitto log file to see what is listed?

  • @daveballard8673
    @daveballard8673 4 ปีที่แล้ว

    Just an FYI, your github link has a comma instead of a password.

    • @BuyAtLess
      @BuyAtLess 3 ปีที่แล้ว

      Avail for hire?

    • @BuyAtLess
      @BuyAtLess 3 ปีที่แล้ว

      shermintelligence@gmail.com

    • @daveballard8673
      @daveballard8673 3 ปีที่แล้ว

      @@BuyAtLess I tried emailing. No reply.

  • @SaadKhan-es3cd
    @SaadKhan-es3cd 2 ปีที่แล้ว

    can this be scaled ?

    • @BurnsHA
      @BurnsHA  2 ปีที่แล้ว

      by what means, what are you needing to do?

  • @o0julek0o
    @o0julek0o 4 ปีที่แล้ว +2

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

    • @BurnsHA
      @BurnsHA  4 ปีที่แล้ว +1

      is there something I can help you with?

    • @matthewwildrick9643
      @matthewwildrick9643 4 ปีที่แล้ว +1

      @@BurnsHA I installed docker and portainer... I have docker compose 1.25 installed as well, but not the yaml file that you mention. Is there a separate video on where that came from

    • @TheBpgoa
      @TheBpgoa 3 ปีที่แล้ว

      @@matthewwildrick9643 - Hi, you create this file and add settings to it as you create containers. When you tell docker-create to start "docker-compose up -d" it reads the file and uses that to determine what to start. just ggogle it..

  • @DjLundbladh
    @DjLundbladh 3 ปีที่แล้ว

    After i re-enter my password i get the message "killed" why ?

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      can you be more specific? are you talking about when you setup your password?

    • @ivanmazan
      @ivanmazan 3 ปีที่แล้ว

      @@BurnsHA The same issue here. Anytime I run mosquitto_passwd -c or -U command it end up with message Killed and nothing happened. Only new empty pwdfile with tmp extension is created

    • @FilipeGOMES
      @FilipeGOMES 3 ปีที่แล้ว

      Same issue here. Do you find the solution ?

    • @TheBpgoa
      @TheBpgoa 3 ปีที่แล้ว

      @@FilipeGOMES - did you make sure you had a shell linked into the container?

  • @BuyAtLess
    @BuyAtLess 3 ปีที่แล้ว

    I'm.teying to figure out of I need this

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      ok, tell me some more about your setup.

  • @hamhumtube
    @hamhumtube 3 ปีที่แล้ว +3

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

    • @hamhumtube
      @hamhumtube 3 ปีที่แล้ว

      Also i assume we must do smt on home assistant side as well. what are these?

    • @hamhumtube
      @hamhumtube 3 ปีที่แล้ว

      hometechhacker.com/mqtt-using-docker-and-home-assistant/#Configuring_Home_Assistant_for_MQTT
      this page gives those

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว

      thanks for the comments!

    • @jeffu.6207
      @jeffu.6207 3 ปีที่แล้ว

      @@BurnsHA Thanks for this. As others have said it would be great if you could update the text above to get rid of the spaces after the colon in the volumes section. I lost a lot of time looking at yaml errors until I figured that out.

    • @TheBpgoa
      @TheBpgoa 3 ปีที่แล้ว

      @@jeffu.6207 try using visual studio code to edit the Yaml files and load a syntax checker ...( actually load the docker plugin) .. it'll save you a ton of wasted life

  • @lamaa422
    @lamaa422 2 ปีที่แล้ว

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

    • @BurnsHA
      @BurnsHA  ปีที่แล้ว

      are you currently using docker-compose for your docker containers? If not, you will need to install docker-compose first

  • @Mare0912
    @Mare0912 3 ปีที่แล้ว +1

    Hi, thank you for the video so far.
    I always get the error message:
    1625649353: Opening ipv4 listen socket on port 1883.
    1625649353: Opening ipv6 listen socket on port 1883.
    1625649353: Error: Address not available
    1625649353: mosquitto version 2.0.11 running
    Do you know, why the address is not asigned or how I can fix it?Thanks in advance!

    • @BurnsHA
      @BurnsHA  3 ปีที่แล้ว +1

      can i see your config you are using for the docker container?

    • @Mare0912
      @Mare0912 3 ปีที่แล้ว +1

      @@BurnsHA I think I've got it. Had to add listener 1883 in the mosquitto.conf