-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker Error: Unable to open log file /mqtt/logs/mosquitto.log for writing. #1078
Comments
I'm also seeing this issue after upgrading my docker container (using eclipse-mosquitto:latest). Running on Docker 18.09.0 CE and Rancher 1.6.21 on CentOS Linux 7 (3.10.0). I have the following volumes mapped to my host as read-write: I've tried deleting the log file and starting the container, but it still throws the same error. |
Have a check on uid and gid mapping between host and container. |
The uid that the image used for the "mosquitto" user had to be set to a fixed value. In previous versions it was set to the next available uid, which was almost certain to clash with an existing system uid, potentially causing permission problems. The uid:gid it now uses is fixed at 1883:1883, so you should be able to update your permissions to match. Apologies for the inconvenience. |
Thanks. I'm using Rancher and NFS volumes, so I had to |
I have the same issue. I have created a mosquitto user with uid and gid 1883.
as root user> 1550395157: Error: Unable to open log file /srv/mosquitto/log/mosquitto.log for writing. I have tried with root 0:0 as well. But I get the same error. I have tried without the -e PGID and -e PUID flag, and I get the same error. I have tried giving the log file global read write permissions (777) and I get the same error. How do I get this running? |
@nilathj Try:
|
No same error: /srv/mosquitto/log# ls -al /srv/mosquitto/log# docker run -it -p 1883:1883 -p 9001:9001 -v /srv/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto. I'm running, Alpine Linux v3.9 as host OS. Docker version 18.09.1-ce. I am running docker as root. If I don't specify an external config, this container runs fine and I can connect to it using an external mqtt client. |
I have the same problem and the mentioned solution also did not work for me. Any further hints? |
same problem here too.
I'll try a few things as suggested in this thread |
for me adding the |
same problem
|
it's a permissions thing. In my case I use
and the docker group in /etc/group (id 996) has the user 'mosquitto' |
indeed, its a permissions issue. But even though I replicate your configuration and adding the user mosquitto to docker group, doesn't fix my problem. I've tried almost everything so far |
@jtomasrl also make sure user (with id 1883 in your example) is also in the docker group and the permissions are set correctly on the file and directory (g+w) |
@proddy the user 1883 is "mosquitto" This is my actual configuration and whatever I do, it doesn't work id mosquitto ls -l cat docker-compose.yml
cat mosquitto.conf
|
the log directory in your compose file is Also I don't use the id of mosquitto (1883) but 1000 which is the owner of my docker |
I was just using a placeholder for the directory, but they match. I tried using mi id 1000 (owner of docker) without luck |
It finally worked for me using @nilathj 's approach. The key was not to create a new mosquitto user on the host system, so the below search returns no results:
Instead I just gave owner rights to 1883 UID/GID for the mqtt root folder on the host machine where all data, logs and configs are stored. And also gave rwx rights.
So the result is:
I assumed that a user / group has to exist on a system in order to be granted ownership but it seems that I have to research this further :) |
I ran into the same problem myself today. My setup is running mosquitto in docker on a Synology nas. For mosquitto, I created the following mqqt-folders:
Starting the image fails with the error message that mosquitto is unable to open the log file for writing. After running the following command:
and restarting mosquitto, everything works like a charm. Note: I did not create a new user for mosquitto on the nas. |
use of directives:
the only solution was:
next:
then run:
next:
and a few minutes after the server starts again:
so that a normal user can read these files from Synology so the mistake is that PID / GUID 1883 is always used maniacally, regardless of what I specified in the startup file |
Tried all of the above. Still not working. |
I've changed the ownership of the volume's directories and it works. |
After trying several things from this thread, this is what worked for me. |
After a while I got it to work.
I use the same user/group for all the containers:
My problem was permissions like most of the people in this tread, so I ran this command:
After all that, restarted the container and no more errors. |
I have exact same issue and i have literally tried EVERYTHING in this issue and more, have spent two days on this before i am writing this. I have a NFS mount on the machine and i use docker-compose and use latest mosquitto. I have tried setting the owner to
No matter what i do i get :
Here is my docker-compose :
Here is the output of the permissions and owner :
Here is my NFS mount in fstab mount :
If anybody has some idea more that has been described in this issue please do share since i don't know what else i can try ? I can see the dockerfile sets the owner of the file to 1883 so even in the cases where i tries to run as another user the container sets the owner of the files to 1883. |
@donnib I'm sorry to hear you're having a tricky time of it.
Starting with the most simple of cases, this message says that the broker doesn't have any read access at all to config directory, so something must not be consistent somewhere because what you've show suggests that it should have the correct permissions. Does the 1883 user exist on the nfs server? You should also note that the |
@ralight thank you replying. No there is no user with that id on the NFS server, i have another NFS folder i am sharing out from same server to a mosquitto broken on another docker host and that works so there seem not to be a requirement that the user must exist on the server other wise t wouldn't have worked there either.
Point taken but in in all my desperate trials i also tried with root so i guess that's when the owner was changed. Is there a way i can troubleshoot more for example have a print of what user tries to read on the docker volume (NFS share) since as you said there must be something that is inconsistent ? |
I'm having the same issue with permissions, except I'm trying to get a conf file in. I get this no matter what I do.
I have no idea why this doesn't work, my permissions are just my user account and i'm not sure why this container can't just read the file. The permissions are this, and i'm not sure if it's SELinux or something else. I'm on Fedora, and I don't think this is a podman issue. |
I had this issue as I was using a file system mount rather than a volume mount so I could store config files in Github. After 3 -4 hours of very great frustration, I gave in and used volume mount and magically problems went away (I needed the config changes manually into the config file) btw I needed to pin mosquito to 2.0.11 as anything more recent does not work with the Schneider PLC
|
I have the same issue. With every other of my containers I using PUID, PGID docker run parameters to bind my local user to container but it doesnt work only in mosquitto. Mosquitto container files and folders permission always turns to 1883. |
Added new issue: #2441 |
Same stuff. I've resolved it this way - after creating the main mosquitto folder |
@ralight is there an example somewhere showing running the docker image and mounting its log directory onto the host machine, including, for example, any control of permissions, directories and mosquitto config file? The example here appears to be insufficient. I found this paragraph but have not been able to use that information to allow the container to access logging directory on the host. I've tried various suggestions on this page (including If there were a complete documented canonical example, that would be a great place to troubleshoot from. Thanks Andy |
I created a file with passwords in a place accessible to the "file station" application, gave everyone read/write permissions, gave a wipe to the file in the config and reinstalled Mosquito. This time it took off without any problems. |
I have a problem with running eclipse image under docker. Particular with the access to the log folder.
Compose file:
And the docker logs:
This is folder permission:
I have also tried creating the
mosquitto.log
file ahead, but no success.When I run the same command with
everything is fine. But I would like to run eclipse image.
P.S. I dont have mosquitto user in my system added.
The text was updated successfully, but these errors were encountered: