Eclipse Mosquitto Docker: Unable to open log file /opt/mosquitto/log/mosquitto.log for writing

Viewed 1482

I want to run the eclipse-mosquitto mqtt server in a docker on a RPi.

The command I am using to run it is:

docker run --name mqtt --restart=always --net=host -tid -u 1883:1883 -v /opt/mosquitto/config:/mosquitto/config:ro -v /opt/mosquitto/log:/mosquitto/log:rw -v /opt/mosquitto/data/:/mosquitto/data/:rw eclipse-mosquitto

When starting up the server, I am getting the following error message:

1615232346: Error: Unable to open log file /opt/mosquitto/log/mosquitto.log for                                                                   writing.

Also from time to time I am getting the following error in the docker logs:

1615241350: Error: No such file or directory.

I assume this one is for the unwriteable data directory.

My mosquitto user looks like this: enter image description here

The rights to the folders in /opt/mosquitto/ looke like this: enter image description here

I even changed the access rights for the mosquitto.log to 777: enter image description here

Unfortunately I am still getting the error. The server is up and running though, but I cannot access the logs and nothing can be written in the data directory. I also already checked multiple solutions (e.g. https://github.com/eclipse/mosquitto/issues/909), but nothing has worked so far.

Can you help me out how to solve this?

1 Answers

I had the same issue. I solved it like this:

first I checked the files' default permission(README) in the ca_certificates and certs folder. It was -rw-r--r-- (644). So I set the all certs files permissions.

sudo chmod 0644 ./ca_certificates/* ./certs/*

and also folders' permissions. they were drwxr-xr-x (755)

sudo chmod 0755 ./ca_certificates ./certs
Related