I have the issue that my Mosquitto broker on my Synology cannot open or access a log file in a directory the docker container is mapped to. The structure it is aiming for exists, I even created the 'mosquitto.log' for it in the attempt to overcome the problem.
I installed Mosquitto in Docker through:
sudo docker run --name="mqtt" --restart=always --net=host -p 1883:1883 -p 9001:9001 -v /volume1/docker/mqtt/config:/mosquitto/config -v /volume1/docker/mqtt/log:/mosquitto/log -v /volume1/docker/mqtt/data:/mosquitto/data -tid eclipse-mosquitto
The container runs, but the log shows
Error: Unable to open log file /mqtt/log/mosquitto.log for writing.
Error: No such file or directory.
Looking for a solution I found this thread -> GitHub but changing ownership or rights does not change a thing.
The container I created goes by the name mqtt and, within my docker directory there is a structure with the following rights:
docker
|_ drwxrwxrwx 1 1883 1883 26 Jan 8 14:33 mqtt
| |_ drwxrwxrwx 1 1883 1883 28 Jan 14 16:57 config
| | |_ -rwxrwxrwx 1 1883 1883 280 Jan 14 17:02 mosquitto.conf
| |_ drwxrwxrwx 1 1883 1883 0 Jan 8 14:33 data
| |_ drwxrwxrwx 1 1883 1883 26 Jan 14 17:09 log
and mosquitto.conf looks like this
persistence true
persistence_location /mqtt/data/
log_dest stdout
log_dest file /mqtt/log/mosquitto.log
log_type warning
log_timestamp true
connection_messages true
and I did not create a user or a group that goes by 1883
CodePudding user response:
-v /volume1/docker/mqtt/log:/mosquitto/log
This makes the folder available as /mosquitto/log
in the container. But in your config you are telling mosquitto to log to /mqtt/log/mosquitto.log
which does not match the above.
Either use -v /volume1/docker/mqtt/log:/mqtt/log
or change the mosquitto.conf
to use /mosquitto/log
(I'd suggest the second option as this matches the defaults used in the docker image; you should also update persistence_location
).