[Bug]: #767

Closed
opened 2026-04-24 23:20:38 +02:00 by adam · 8 comments
Owner

Originally created by @oucil on GitHub (Nov 19, 2022).

Describe the issue

First, I'm sorry but I'm relatively new to Docker and there are no instructions for installing in distros except for deb. I'm trying to get this running for the first time and I'm getting permission errors on the docker run... command relating to the initial creation of directories.

I've created a directory at /srv/audiobookshelf/ in order to house the persistent data, within it are the ./config and ./metadata/ folders. Everything at this point is root:root owned and 755.

The command I'm running is, with the exception of the actual paths, what's described in the current docker instructions (I don't have podcasts so I've removed that volume)...

docker run -d \
  -e AUDIOBOOKSHELF_UID=99 \
  -e AUDIOBOOKSHELF_GID=100 \
  -p 13378:80 \
  -v /srv/audiobookshelf/config:/config \
  -v /srv/audiobookshelf/metadata:/metadata \
  -v /media/audiobooks:/audiobooks \
  --name audiobookshelf ghcr.io/advplyr/audiobookshelf

I'm getting the following error when I run docker logs .... when the container fails to start...

> audiobookshelf@2.2.4 start
> node index.js
Config /config /metadata
/server/libs/njodb/index.js:103
        throw error;
        ^
Error: EACCES: permission denied, mkdir '/config/libraryItems'
    at mkdirSync (node:fs:1382:3)
    at new Database (/server/libs/njodb/index.js:121:48)
    at new Db (/server/Db.js:28:27)
    at new Server (/server/Server.js:65:15)
    at Object.<anonymous> (/index.js:28:16)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  errno: -13,
  syscall: 'mkdir',
  code: 'EACCES',
  path: '/config/libraryItems'
}

It seems to have permission issues writing inside the persistent folders I've created. So I tried creating an audiobookshelf:audiobookshelf user/group and then running the docker run --user xxx:xxx ... but that led to a slightly different error indicating that the /.npm folder had the wrong permissions.

I'm lost here and need some guidance. I would be more than happy to help contribute to updating documentation for non-debian installs once this gets sorted out!

Cheers!

Steps to reproduce the issue

Try to install and run on a non-deb system? Sorry details are above.

Audiobookshelf version

2.2.4

How are you running audiobookshelf?

Docker

Originally created by @oucil on GitHub (Nov 19, 2022). ### Describe the issue First, I'm sorry but I'm relatively new to Docker and there are no instructions for installing in distros except for deb. I'm trying to get this running for the first time and I'm getting permission errors on the `docker run...` command relating to the initial creation of directories. I've created a directory at `/srv/audiobookshelf/` in order to house the persistent data, within it are the `./config` and `./metadata/` folders. Everything at this point is `root:root` owned and 755. The command I'm running is, with the exception of the actual paths, what's described in the current docker instructions (I don't have podcasts so I've removed that volume)... ```` docker run -d \ -e AUDIOBOOKSHELF_UID=99 \ -e AUDIOBOOKSHELF_GID=100 \ -p 13378:80 \ -v /srv/audiobookshelf/config:/config \ -v /srv/audiobookshelf/metadata:/metadata \ -v /media/audiobooks:/audiobooks \ --name audiobookshelf ghcr.io/advplyr/audiobookshelf ```` I'm getting the following error when I run `docker logs ....` when the container fails to start... ```` > audiobookshelf@2.2.4 start > node index.js Config /config /metadata /server/libs/njodb/index.js:103 throw error; ^ Error: EACCES: permission denied, mkdir '/config/libraryItems' at mkdirSync (node:fs:1382:3) at new Database (/server/libs/njodb/index.js:121:48) at new Db (/server/Db.js:28:27) at new Server (/server/Server.js:65:15) at Object.<anonymous> (/index.js:28:16) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) { errno: -13, syscall: 'mkdir', code: 'EACCES', path: '/config/libraryItems' } ```` It seems to have permission issues writing inside the persistent folders I've created. So I tried creating an `audiobookshelf:audiobookshelf` user/group and then running the `docker run --user xxx:xxx ...` but that led to a slightly different error indicating that the `/.npm` folder had the wrong permissions. I'm lost here and need some guidance. I would be more than happy to help contribute to updating documentation for non-debian installs once this gets sorted out! Cheers! ### Steps to reproduce the issue Try to install and run on a non-deb system? Sorry details are above. ### Audiobookshelf version 2.2.4 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:20:38 +02:00
adam closed this issue 2026-04-24 23:20:39 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 19, 2022):

The docker container will have to be run by the root user in your case since the permissions are 755 and owned by root on those folders.
The AUDIOBOOKSHELF_UID/GID env variables are what Abs will use as the owner when it has to create new files/folders.

For the future the best place for troubleshooting is the discord server or the matrix server that are very active. Links for those on the website.

@advplyr commented on GitHub (Nov 19, 2022): The docker container will have to be run by the root user in your case since the permissions are 755 and owned by root on those folders. The AUDIOBOOKSHELF_UID/GID env variables are what Abs will use as the owner when it has to create new files/folders. For the future the best place for troubleshooting is the discord server or the matrix server that are very active. Links for those on the website.
Author
Owner

@oucil commented on GitHub (Nov 20, 2022):

Thanks for the heads up @advplyr, didn't notice the discord channel, will head there next time.

While I have you though, just to confirm, if I go back to my second attempt using a custom system user I created called audiobookshelf along with assigning that to the docker container, and then assign it's uid/gid to the AUDIOBOOKSHELF_UID/GID values, that should take care of the permission issues?

On the other hand, what should the ownership/permissions be on persistent folders normally, if docker is run by root by default and the container is using the nobody:users in AUDIOBOOKSHELF_UID/GID?

I'll give that a shot and if it works, I'll put something together for the docs.

Cheers!

@oucil commented on GitHub (Nov 20, 2022): Thanks for the heads up @advplyr, didn't notice the discord channel, will head there next time. While I have you though, just to confirm, if I go back to my second attempt using a custom system user I created called `audiobookshelf` along with assigning that to the docker container, and then assign it's uid/gid to the AUDIOBOOKSHELF_UID/GID values, that should take care of the permission issues? On the other hand, what should the ownership/permissions be on persistent folders normally, if docker is run by root by default and the container is using the `nobody:users` in AUDIOBOOKSHELF_UID/GID? I'll give that a shot and if it works, I'll put something together for the docs. Cheers!
Author
Owner

@advplyr commented on GitHub (Nov 20, 2022):

Whatever user you are using to run the docker container is important.
If you use root user to run the docker container then that would solve your problem since the folders Abs will need write access to are owned by root.

If you don't want to use root then you need to change the owner of those config and metadata folders.

Docker also has the ability to set the user using the run command, you could look that up if it is useful to you.

@advplyr commented on GitHub (Nov 20, 2022): Whatever user you are using to run the docker container is important. If you use root user to run the docker container then that would solve your problem since the folders Abs will need write access to are owned by root. If you don't want to use root then you need to change the owner of those config and metadata folders. Docker also has the ability to set the user using the run command, you could look that up if it is useful to you.
Author
Owner

@advplyr commented on GitHub (Nov 20, 2022):

You are confusing AUDIOBOOKSHELF_UID/GID with what the container user actually is.
Those env variables are only what you are telling Abs to set as the owner once it creates new files/folders. Those are not the actual owner/group of the container.

@advplyr commented on GitHub (Nov 20, 2022): You are confusing AUDIOBOOKSHELF_UID/GID with what the container user actually is. Those env variables are only what you are telling Abs to set as the owner once it creates new files/folders. Those are not the actual owner/group of the container.
Author
Owner

@oucil commented on GitHub (Nov 20, 2022):

The AUDIOBOOKSHELF_UID/GID env variables are what Abs will use as the owner when it has to create new files/folders.

I must be confusing what you're saying. I've updated the ownership of the config/metadata folders to audiobookshelf (the system user I created to run the container. Then I've updated the docker run to the following with 994:992 being the user:group of the 'audiobookshelf' user...

docker run -d \
  -e AUDIOBOOKSHELF_UID=994 \
  -e AUDIOBOOKSHELF_GID=992 \
  -p 13378:80 \
  -v /srv/audiobookshelf/config:/config \
  -v /srv/audiobookshelf/metadata:/metadata \
  -v /media/audiobooks:/audiobooks \
  --user 994:992 \
  --name audiobookshelf ghcr.io/advplyr/audiobookshelf

This is still producing the npm error I mentioned originally...

> audiobookshelf@2.2.4 start
> node index.js
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 994:992 "/.npm"
npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

I must be missing a step here. Sorry for the hassle, but I appreciate your help!

@oucil commented on GitHub (Nov 20, 2022): > The AUDIOBOOKSHELF_UID/GID env variables are what Abs will use as the owner when it has to create new files/folders. I must be confusing what you're saying. I've updated the ownership of the config/metadata folders to `audiobookshelf` (the system user I created to run the container. Then I've updated the docker run to the following with 994:992 being the user:group of the 'audiobookshelf' user... ```` docker run -d \ -e AUDIOBOOKSHELF_UID=994 \ -e AUDIOBOOKSHELF_GID=992 \ -p 13378:80 \ -v /srv/audiobookshelf/config:/config \ -v /srv/audiobookshelf/metadata:/metadata \ -v /media/audiobooks:/audiobooks \ --user 994:992 \ --name audiobookshelf ghcr.io/advplyr/audiobookshelf ```` This is still producing the npm error I mentioned originally... ```` > audiobookshelf@2.2.4 start > node index.js npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /.npm npm ERR! errno -13 npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. npm ERR! npm ERR! To permanently fix this problem, please run: npm ERR! sudo chown -R 994:992 "/.npm" npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal ```` I must be missing a step here. Sorry for the hassle, but I appreciate your help!
Author
Owner

@advplyr commented on GitHub (Nov 20, 2022):

What user are you logged in as when you are executing that run command?

@advplyr commented on GitHub (Nov 20, 2022): What user are you logged in as when you are executing that run command?
Author
Owner

@wadebee commented on GitHub (Apr 30, 2023):

I've got this same issue trying to run this container in TrueNAS Scale (k3s orchestrator). By convention containers are running as uid/guid: 568.

As the error above mentions there appears to be a bug in npm:

npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.

Such that any attempts to run this container as a non-root user fail.
Looking at the multi-stage Dockerfile I see that on line 5 the npm setup for the Build container is using
RUN npm ci && npm cache clean --force

But then on line 24 for the Runtime container you are using
RUN npm ci --only=production

Can this problem be corrected by changing line 24 to
RUN npm ci --only=production && npm cache clean --force

Refer to https://stackoverflow.com/questions/59437833/error-your-cache-folder-contains-root-owned-files-due-to-a-bug-in-previous-ver for some additional context

@wadebee commented on GitHub (Apr 30, 2023): I've got this same issue trying to run this container in TrueNAS Scale (k3s orchestrator). By convention containers are running as uid/guid: 568. As the error above mentions there appears to be a bug in npm: ``` npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. ``` Such that any attempts to run this container as a non-root user fail. Looking at the multi-stage [Dockerfile](https://github.com/advplyr/audiobookshelf/blob/b707d6f3c9dc8ea3aa81408daa99ba10e60fccbd/Dockerfile) I see that on line 5 the npm setup for the _**Build**_ container is using `RUN npm ci && npm cache clean --force` But then on line 24 for the _**Runtime**_ container you are using `RUN npm ci --only=production` Can this problem be corrected by changing line 24 to `RUN npm ci --only=production && npm cache clean --force` Refer to https://stackoverflow.com/questions/59437833/error-your-cache-folder-contains-root-owned-files-due-to-a-bug-in-previous-ver for some additional context
Author
Owner

@advplyr commented on GitHub (Apr 30, 2023):

We changed npm run start command to node index.js so that we don't use an npm process.

@advplyr commented on GitHub (Apr 30, 2023): We changed `npm run start` command to `node index.js` so that we don't use an npm process.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#767