#Mosquitto container issue

1 messages · Page 1 of 1 (latest)

snow pilot
#

Please share the complete compose file and log.

#

How are you starting it?

buoyant iron
#

docker compose -f /opt/docker-compose.yml up -d

snow pilot
#

Check with docker logs -t mqtt5.

buoyant iron
#

or something like that it is an alias so i forget the exact command

snow pilot
#

You can check with alias.

buoyant iron
#

alias dcp='docker compose -f /opt/docker-compose.yml '

#

then dcp up -d

snow pilot
#

Yeah that's fine.

buoyant iron
#
sanfordg@mab:~$ docker logs -t mqtt5
sanfordg@mab:~$ docker ps
CONTAINER ID   IMAGE                                          COMMAND                  CREATED         STATUS                    PORTS                                                                         NAMES
aa233ad02e1f   eclipse-mosquitto                              "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes              0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:9001->9001/tcp, :::9001->9001/tcp                                  mqtt5
bfa8fafb5d4d   nodered/node-red                               "./entrypoint.sh"        7 days ago      Up 25 minutes (healthy)   0.0.0.0:1880->1880/tcp, :::1880->1880/tcp                                     nodered
7af4c2897489   ghcr.io/home-assistant/home-assistant:stable   "/init"                  7 days ago      Up 25 minutes                                                                                           homeassistant_DCP
c1b7692f3152   zwavejs/zwave-js-ui                            "node server/bin/www"    7 days ago      Up 25 minutes             0.0.0.0:3000->3000/tcp, :::3000->3000/tcp, 0.0.0.0:8091->8091/tcp, :::8091->8091/tcp                                  zwavejs2
5f7b6ebe8013   portainer/portainer:latest                     "/portainer"             2 weeks ago     Up 25 minutes             8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp                 portainer
b37a310df10e   traefik:v2.2                                   "/entrypoint.sh --co…"   2 weeks ago     Up 25 minutes             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   traefik
#

becuase the lack of logs is unbelible

snow pilot
#

Try docker compose -f /opt/docker-compose.yml up mqtt5.

buoyant iron
#

hanging on Attaching to mqtt5

snow pilot
#

Hmm. Try docker compose -f /opt/docker-compose.yml down mqtt5, then try again.

buoyant iron
#

already did

#

well clt c, stopped mqtt5, did a docker ps to double check it wasn't running

#

then ran the command again and it hung

snow pilot
#

I replicated your setup and it works fine here with your config.

buoyant iron
#

oh didn't have the -d that is what it was "hanging"

#

but still no logs

snow pilot
#

The -d just puts it in the background. We don't want this right now.

buoyant iron
#

i know

#

but it wasn't returning the prompt which is why i was thinking it was hanging on startup

#

explained by running it in the background

#

ok, lets start this from scratch

#

i am going to delete teh folders and try from that

snow pilot
#

Just for reference

# docker compose -f /opt/docker-compose.yml up mqtt5
[+] Running 1/0
 ✔ Container mqtt5  Created                                                                                                                                                                                                                                               0.0s
Attaching to mqtt5
mqtt5  | 1713887920: mosquitto version 2.0.18 starting
mqtt5  | 1713887920: Config loaded from /mosquitto/config/mosquitto.conf.
mqtt5  | 1713887920: Opening ipv4 listen socket on port 1883.
mqtt5  | 1713887920: mosquitto version 2.0.18 running
buoyant iron
#

when you recreated it did you create anything?

#

when i did that all it did was get to "attaching to mqtt5"

snow pilot
#

did you create anything?
Like what? I only created the mosquitto.conf.

buoyant iron
#

i meant directory struture

snow pilot
#

Maybe try pulling the latest image if not already: docker compose -f /opt/docker-compose.yml pull mqtt5
But strange because it worked a minute ago.

#

No I let it create everything. It creates a mosquitto.conf/ directory that way so I deleted this and created a file with your config values instead.

#
# namei /opt/appdata/mosquitto/*
f: /opt/appdata/mosquitto/data
 d /
 d opt
 d appdata
 d mosquitto
 d data
f: /opt/appdata/mosquitto/log
 d /
 d opt
 d appdata
 d mosquitto
 d log
f: /opt/appdata/mosquitto/mosquitto.conf
 d /
 d opt
 d appdata
 d mosquitto
 - mosquitto.conf
# ls -l /opt/appdata/mosquitto/
total 12
drwxr-xr-x 2 1883 1883 4096 Apr 23 17:54 data
drwxr-xr-x 2 1883 1883 4096 Apr 23 17:54 log
-rw-r--r-- 1 1883 1883   22 Apr 23 17:58 mosquitto.conf
buoyant iron
#

now that is intresting becuse it dosn't want to create it for me

snow pilot
#

But it worked before you edited the path? Very weird.

buoyant iron
#

yes

#

so i went back to the preedited path

#

/opt/appdata/mosquitto/mosquitto.conf:/mosquitto/mosquitto.conf

snow pilot
#

And that works?

buoyant iron
#

and it creates it as a directory drwxr-xr-x 2 1883 1883 4096 Apr 23 12:06 mosquitto.conf

#

so it works as in the container comes up

#

but there is no configs for it (just realized this part)

snow pilot
#

Can you share your compete mosquitto config?

buoyant iron
#

which explains my inital problem/question

#

right now there is none

snow pilot
#

Please also always share the command prompt like I did when you show command outputs.

buoyant iron
#
sanfordg@mab:~$ sudo rm /opt/appdata/mosquitto/
rm: cannot remove '/opt/appdata/mosquitto/': Is a directory
sanfordg@mab:~$ sudo rm -rf /opt/appdata/mosquitto/
sanfordg@mab:~$ ls -la /opt/appdata/mosquitto/
total 12
drwxr-xr-x  3 root       root       4096 Apr 23 12:06 .
drwxr-xr-x 12 dockeruser dockeruser 4096 Apr 23 12:06 ..
drwxr-xr-x  2       1883       1883 4096 Apr 23 12:06 mosquitto.conf
sanfordg@mab:~$ vi /opt/appdata/mosquitto/mosquitto.conf/
#
sanfordg@mab:~$ dcp up mqtt
[+] Running 0/1
⠹ Container mqtt  Recreated                                                                                                                                                                              0.2s 
Attaching to mqtt
mqtt  | 1713888377: mosquitto version 2.0.18 starting
mqtt  | 1713888377: Config loaded from /mosquitto/config/mosquitto.conf.
mqtt  | 1713888377: Starting in local only mode. Connections will only be possible from clients running on this machine.
mqtt  | 1713888377: Create a configuration file which defines a listener to allow remote access.
mqtt  | 1713888377: For more details see https://mosquitto.org/documentation/authentication-methods/
mqtt  | 1713888377: Opening ipv4 listen socket on port 1883.
mqtt  | 1713888377: Opening ipv6 listen socket on port 1883.
mqtt  | 1713888377: mosquitto version 2.0.18 running
snow pilot
#

Stop the container and run

rmdir /opt/appdata/mosquitto/mosquitto.conf
echo "listener 1883 0.0.0.0" > /opt/appdata/mosquitto/mosquitto.conf

Then try again.

#

You might want to chown -R ... the /opt/appdata/mosquitto directory.

buoyant iron
#
sanfordg@mab:~$ sudo echo "listener 1883 0.0.0.0" > /opt/appdata/mosquitto/mosquitto.conf
-bash: /opt/appdata/mosquitto/mosquitto.conf: No such file or directory
#

wont' let me just echo to it

snow pilot
#

Run mkdir -p /opt/appdata/mosquitto/ first.

buoyant iron
#

well that is intresting

sanfordg@mab:~$ sudo echo "listener 1883 0.0.0.0" > /opt/appdata/mosquitto/mosquitto.conf
-bash: /opt/appdata/mosquitto/mosquitto.conf: Permission denied
#

never got that from sudo

snow pilot
#

Probably because of the redirect. It pobably does the part before the > as root and the rest as your user.

#

Try sudo -i and work as root for now.

buoyant iron
#

well that seemed to have worked

buoyant iron
#
sanfordg@mab:~$ dcp up mqtt
[+] Running 0/1
⠹ Container mqtt  Recreated                                                                                                                                                                              0.2s 
Attaching to mqtt
mqtt  | 1713888935: mosquitto version 2.0.18 starting
mqtt  | 1713888935: Config loaded from /mosquitto/config/mosquitto.conf.
mqtt  | 1713888935: Opening ipv4 listen socket on port 1883.
mqtt  | 1713888935: mosquitto version 2.0.18 running
#

of course, the real question is why

#

don't get me wrong glad it is working but what is different

snow pilot
#

You can know this better than I do. You know your environment best.

buoyant iron
#

it is like the container didn't like the file being created by VI or through SMB

snow pilot
#

Remove the file and try to create it again. My guess is it was a directory like in my case or something like that.

# rm mosquitto.conf
# docker compose -f /opt/docker-compose.yml up mqtt5
Attaching to mqtt5
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/opt/appdata/mosquitto/mosquitto.conf" to rootfs at "/mosquitto/config/mosquitto.conf": mount /opt/appdata/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

Not sure why it didn't complain for you.

buoyant iron
#

should i put the other stuff back in there?

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
#

and great news HA is now connected to it

snow pilot
#

If you want.

buoyant iron
#

what persistance is there with MQTT? i though the hole point was send it and forget it

snow pilot
#

Retained messages are a thing.

#

Hmm. It might have been log_dest. Maybe it stops logging to console then.

#

I already teared down my test VM and I don't want to replicate it again so you have to test that yourself.

buoyant iron
#

thats fine, thank you for your help

snow pilot