Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting mongo through docker on a Synology NAS

I'm new to containers and docker, so bear with me. I'm trying to get mongo up and running on a Synology NAS where the db files are stored in a share folder (different than the docker folder created). All users have full read/write access but the following error keeps coming up.

STORAGE [initandlisten] exception in initAndListen std ::exception:boost::filesystem::status: Permission denied: "/data/db/storage.bson", terminating

Mongo Error

This is how I have the container folder structure set up. I think the issue is a result of the virtual drive mapping, but I'm not sure. As always, any help would be greatly appreciated. Drive Mapping

EDIT: Adding the permissions for /share/data/db below.

Folder permissions

like image 652
user1991179 Avatar asked Jan 06 '23 15:01

user1991179


2 Answers

Let me give a Synology-related answer if it is a Synology-related question. I have decided to play docker on my NAS and got trapped into the same problem. I do not really like giving permissions for everyone and I found a solution how to make mongo work via docker on a Synology NAS. I have added a Read/Write permission record for the Owner group in case of the shared folder on the host. The name of the folder is "mongo1" in my case (this one is mapped to the "/data/db" path inside the container).

It seems, mongo touches this directory and changes its owner during startup (UID changes to 999). This user doesn't exists on the host machine, but it doesn't matter anyway. Thanks to the newly set permission rule the bootup process can continue.

I hope it will help someone someday. Cheers! :)

Screenshot: adding Owner Read and Write permission

like image 126
Szmeby Avatar answered Jan 09 '23 05:01

Szmeby


Adding answer from comment for posterity...

This issue stems from the MongoDB process inside the Docker container running as a user that does not have permissions on the host machine. The easiest, but perhaps least secure fix is to mark the host volume with read and write permissions for everyone (chmod 777).

Check out this post for more details and more "proper" solutions. What is the (best) way to manage permissions for docker shared volumes

like image 29
Kevin Burdett Avatar answered Jan 09 '23 04:01

Kevin Burdett