Docker container images installation help

  • Hi


    I have tried to installed Mosquitto into Docker again fresh install OMV , however i have the following error as i am new to Docker and OMV , could someone advise how i can install the Mosquitto.conf file into the container the most simple and easy ways. I need this file for MQTT to run. (i have the file in Visual Studio code )


    Any help would really be appreciated.


    thanks in advance



    Code
    <img src="https://forum.openmediavault.org/wsc/index.php?attachment/19701-screenshot-2021-05-04-at-08-21-44-png/&thumbnail=1" class="woltlabAttachment" data-attachment-id="19701" id="wcfImgAttachment0">
  • You need to create the file before running the container.


    Post your yml and it will be easier to help you.

    Don't forget to mask sensible data.

  • Hi Soma


    Thanks for you quick response. I created the file below on VIM attached it to the Mosquitto/config directory , thinking that it would be read by the container. I am novice with docker & docker compose at the moment been using Home assistant mainly. i suppose i need need to learn more and create a docker compose yaml file ?


    Mqtt Conf File

    persistence true

    persistence_location /mosquitto/data/

    log_dest file /mosquitto/log/mosquitto.log

    #password_file /mosquitto/config/pwfile

    allow_anonymous true

    listener 1883 192.168.x.xxx


    i await your comments,

  • Maybe I'm wrong... but to me the problem looks clear from the error.


    /mosquitto/config/mosquitto.conf is a directory


    If I were a guessing man it is picking up "mosquitto.conf" as a directory since it is mapped as a volume, and it is looking for a configuration file.


    Try changing that volume to this (one on the left is host, right is the container path):

    Code
    /volume1/docker/mqtt/config    /mosquitto/config


    and restart the container.

    Air Conditioners are a lot like PC's... They work great until you open Windows.


  • Can you point me to the site you follow the instructions to create the container???

    Which image is it using?


    One thing that assumes an error is your host path: /volume1/docker/mqtt


    Does this path exist?


    [EDIT]

    This is a good guide to run it from docker: Running the eclipse-mosquitto MQTT Broker in a docker container - Sticky Bits - Powered by FeabhasSticky Bits – Powered by Feabhas

  • Hi


    I did understand the error message just didn't understand why container is not reading the file.

    I changed the volume directories as suggested and i am still getting the error message. The question is how do i insert these details into config for the container


    persistence true

    persistence_location /mosquitto/data/

    log_dest file /mosquitto/log/mosquitto.log

    #password_file /mosquitto/config/pwfile

    allow_anonymous true

    listener 1883 192.168.x.xxx

  • HannesJo


    here is the details :

    root@raspberrypi:/var/lib/docker/mqtt/config# ls -la

    total 12

    drwxr-xr-x 2 root root 4096 May 4 07:18 .

    drwxr-xr-x 5 root root 4096 May 4 07:05 ..

    -rw-r--r-- 1 root root 189 May 4 07:18 mosquitto.conf

  • Below is the command to download the image , I have stop and restarted several time with the same error. Is it possible for me to delete the container only keep the image and insert all the correct parameters( what every they are ) manually ?



    root@raspberrypi:/var/lib/docker/mqtt/config# sudo docker run --name=mqtt -itd --restart=always --net=host -v /volume1/docker/mqtt/config:/mosquitto/config -v /volume1/docker/mqtt/data:/mosquitto/data -v /volume1/docker/mqtt/log:/mosquitto/log -v /volume1/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto


    Unable to find image 'eclipse-mosquitto:latest' locally

    latest: Pulling from library/eclipse-mosquitto

    b452d2916bdf: Pull complete

    862b9e7501b2: Pull complete

    db1bede1c78a: Pull complete

    Digest: sha256:683189aaaf01240fe4ba3c0b3262704c4a3910c7293162e22e8f43a319fc9ed8

    Status: Downloaded newer image for eclipse-mosquitto:latest

    cb54d7ad925e812f4f26083b8bfa4c75ab8e6ff508cd1b7c00de5ca8f186d037


    This is what are the details in portainer.


    I really appreciated you help

    Code
    <img src="https://forum.openmediavault.org/wsc/index.php?attachment/19703-screenshot-2021-05-04-at-14-59-59-png/&thumbnail=1" class="woltlabAttachment" data-attachment-id="19703" id="wcfImgAttachment0">
  • root@raspberrypi:/var/lib/docker/mqtt/config# sudo docker run --name=mqtt -itd --restart=always

    You are running the command as "root", (which you shouldn't) so you don't need the "sudo".


    See the guide I posted above to make a proper "docker run"

  • You should concentrate on one topic. When the error message is solved then you can take care of remaining questions. Why do you enter -v /volume1/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf? The config folder is already bound with -v /volume1/docker/mqtt/config:/mosquitto/config

  • HannesJo


    I am trying to resolve error , this was my original question, I am new to all this, the only way to learn is to as ask for guidance on what has to be done. You say my conf is a file and is bound to config so why is not being read ?

    What do i have to do to fix the error if script for the dat, log and config are correct so that i can move on ?

  • Why do you enter -v /volume1/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf? The config folder is already bound with -v /volume1/docker/mqtt/config:/mosquitto/config


    If I were a guessing man it is picking up "mosquitto.conf" as a directory since it is mapped as a volume, and it is looking for a configuration file.


    Try without -v /volume1/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf

  • If @OP take a few minutes and see the guide I posted, He will have it running in no time:


  • I have tried for days now to solve it on my own , but there comes a point when you need guidance from the experts . I followed yours and i have the same result . This time i installed the 3 volumes manually. It showed that it connected to the ports then when off.


    1620144194: Error: Config file /mosquitto/config/mosquitto.conf is a directory.

    1620144208: Error: Config file /mosquitto/config/mosquitto.conf is a directory.

    1620144235: Error: Config file /mosquitto/config/mosquitto.conf is a directory.

    1620144287: Error: Config file /mosquitto/config/mosquitto.conf is a directory.

  • Some people want to understand and solve a problem and not just take another guide

    Don't want to sound harsh, but the problem is solved by reading.

    Will it be guides or books or even the subtitles of a Youtube video.


    There are errors upfront that shouldn't be there in the first place:

    One should never run docker containers with "root", ever.


    For the @OP, to start clean,

    Stop the container and remove it.


    On a terminal, add a "normal" user to the docker group sudo usermod -aG docker <normalusername>


    Now, login with that user and go to his home cd /home/<username>/

    Now mkdir -p docker-mosquitto

    cd docker-mosquitto/

    mkdir -p mosquitto/config/

    mkdir -p mosquitto/data/

    mkdir -p mosquitto/log/


    Now make a conf file nano mosquitto/config/mosquitto.conf

    Copy/Paste this onto the file:

    Code
    # following two lines required for > v2.0
    allow_anonymous true
    listener 1883
    persistence true
    persistence_location /mosquitto/data/
    log_dest file /mosquitto/log/mosquitto.log

    Click Ctrl+X and Y.


    Now, run this commands:

    docker pull eclipse-mosquitto


    Change the <username> with the name from above ---^^^^ (this is one single command)

    docker run -it --name mosquitto -p 1883:1883 -v /home/<username>/docker-mosquitto/mosquitto/config:/mosquitto/config/ -v /home/<username>/docker-mosquitto/mosquitto/data:/mosquitto/data/ -v /home/<username>/docker-mosquitto/mosquitto/log:/mosquitto/log/ eclipse-mosquitto


    Profit.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!