psi-4ward / psitransfer

Simple open source self-hosted file sharing solution.
BSD 2-Clause "Simplified" License
1.45k stars 211 forks source link

Error: db initialization failed with error EACCES: permission denied, scandir '/data' #305

Closed joelguittet closed 3 months ago

joelguittet commented 3 months ago

Hello,

Nice solution but difficulties here to configure the /data directory using Docker on Synology NAS. My configuration is the following:

me@DiskStation:/volume3/psitransfer$ ll
total 0
drwxrwxrwx+ 1 root root  20 Apr  6 22:02 .
drwxr-xr-x  1 root root  70 Apr  6 21:46 ..
drwxrwxrwx+ 1 1000 users  0 Apr  6 22:02 data

But despite this I get the following error while binding the /volume3/psitransfer/data directory to /data in docker volume configuration:

/app/lib/db.js:50
      throw e;
      ^

Error: db initialization failed with error EACCES: permission denied, scandir '/data'
    at Object.readdirSync (fs.js:1021:3)
    at DB._sync (/app/lib/db.js:61:9)
    at DB.init (/app/lib/db.js:46:12)
    at Object.<anonymous> (/app/lib/endpoints.js:32:4)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18) {
  errno: -13,
  syscall: 'scandir',
  code: 'EACCES',
  path: '/data'
}

I have seen 2 or 3 issues here speaking of this topic but they just mention to use the chown command .... Seems the issue is something else...

Any feedback appreciated :-)

Thanks, Joel

joelguittet commented 3 months ago

Answering myself to the issue, I had the following idea, which has properly worked.

Start the container but binding /volume3/psitransfer/data to /somethingelse. Then go in the container with a command like sudo docker exec -it <container id> /bin/sh. Execute the following IN the container: chown -R 1000:root /somethingelse. Execute the following IN the container: chmod 755 /somethingelse.

Then exit, stop the container and start again but binding /volume3/psitransfer/data to /data. Working. This trick permit to properly setup the data directory of the volume.

Joel