cmccambridge / mosquitto-unraid

Docker container for eclipse-mosquitto with unRAID ease-of-use tweaks
18 stars 7 forks source link

Error: Unable to open log file /mosquitto/log/mosquitto.log for writing. #28

Open cpfowler opened 1 year ago

cpfowler commented 1 year ago

Fixed the passwd permissions problem: https://github.com/cmccambridge/mosquitto-unraid/issues/27

Now I have what seems to be the exact same problem, but for the log file: 1659577565: Loading config file /mosquitto/config/mosquitto-unraid-default.conf 1659577565: Error: Unable to open log file /mosquitto/log/mosquitto.log for writing. 1659577715: Error: Permission denied.

I tried creating the logfile myself, then setting the permissions for it. Ran the same 2 commands from Unraid webGUI terminal (which fixed passwd problem): chown -R 99:100 /mnt/user/appdata/mosquitto chmod -R 775 /mnt/user/appdata/mosquitto

cmccambridge commented 1 year ago

@cpfowler Could you share how you have configured mosquitto-unraid?

e.g.:

cpfowler commented 1 year ago

I was able to fix this with more permission changes. I looked through the docker image layers, and found where you create the user and group 1883:1883

So in Unraid's webGUI terminal, I used chown -R 1883:1883 and chmod -R 775 on Mosquitto's appdata folder. After that, no more permission errors for passwd file, and /logs.

I THINK the problem is this Unraid specific docker image isn't setting folder permissions/owner correctly when they're created; such as /appdata/mosquitto/; /appdata/mosquitto/logs/; and /appdata/mosquitto/passwd when using "mosquitto_passwd." Without doing any customizations nor changes to the default Unraid Docker template, other than setting an IP address, it gave me 2 permissions errors I had to fix.

Here's the info requested: root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='Mosquitto' --net='br0.2' --ip='192.168.2.22' -e TZ="America/Chicago" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Tower" -e HOST_CONTAINERNAME="Mosquitto" -e 'RUN_INSECURE_MQTT_SERVER'='0' -e 'TCP_PORT_1883'='1883' -e 'TCP_PORT_8883'='' -e 'TCP_PORT_9001'='9001' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.icon='https://raw.githubusercontent.com/cmccambridge/mosquitto-unraid/master/media/eclipse-mosquitto.png' -v '/mnt/user/appdata/mosquitto':'/mosquitto/config':'rw' -v '/mnt/user/appdata/mosquitto/data':'/mosquitto/data':'rw' -v '/mnt/user/appdata/mosquitto/log':'/mosquitto/log':'rw' 'cmccambridge/mosquitto-unraid:latest' 19943c6e0dbe9f5dfb1fd451f3362794c9773e4507609efc2d7a7f35a2511ebe

Only customizations I made to the docker template was changing network to my br0.2 and giving it an internal IP.

I mounted /mnt/user/appdata/mosquitto/logs/ for the log directory.

I didn't add any extra options for the user, PUID, PGID, nor UMASK.

mosquitto_unraid_template

xm4rcell0x commented 1 year ago

Error: Unable to open log file /mosquitto/log/mosquitto.log for writing. I had the same problem. chown -R 1883:1883 /mnt/user/appdata/mosquitto and chmod -R 775 /mnt/user/appdata/mosquitto solved my problem. Thanks!

chadblose commented 6 months ago

I have tried the above permission change suggestions but I'm still getting errors unable to read the file. Inside the container the user and group are both mosquitto with permissions -rwxrwxr-x. In Unraid, 1883 is the group and user.

nerdosity commented 2 months ago

This is still happening. I had to reset the permissions like @xm4rcell0x suggested, and it worked