[Bug]: UID/GID parameters ignored #786

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

Originally created by @freezeeedos on GitHub (Nov 28, 2022).

Describe the issue

Hello

First of all, thanks for audiobookshelf, it's a great app !

I'm noticing that the following variables are ignored:

environment:
      - AUDIOBOOKSHELF_UID=1000
      - AUDIOBOOKSHELF_GID=1000

Node is still running as root:

docker exec -it audiobookshelf /bin/sh
PID   USER     TIME  COMMAND
    1 root      0:00 npm start
   18 root      0:07 node index.js
  307 root      0:00 /bin/sh
  315 root      0:00 ps aux

This is resulting in files being written as root on the host system, instead of them being written as the intended user:

~/audiobookshelf/config/users/data$ ls -lhrt
total 4.0K
-rw-r--r-- 1 root root    0 Nov 28 09:40 data.2.json
-rw-r--r-- 1 root root 1.2K Nov 28 09:40 data.4.json

Steps to reproduce the issue

  1. Set up audiobookshelf using docker compose with the following env variables: AUDIOBOOKSHELF_UID=1000, AUDIOBOOKSHELF_GID=1000
  2. Open a shell in the container
  3. The process is running as root, not UID 1000

Audiobookshelf version

v2.2.6

How are you running audiobookshelf?

Docker

Originally created by @freezeeedos on GitHub (Nov 28, 2022). ### Describe the issue Hello First of all, thanks for audiobookshelf, it's a great app ! I'm noticing that the following variables are ignored: ``` environment: - AUDIOBOOKSHELF_UID=1000 - AUDIOBOOKSHELF_GID=1000 ``` Node is still running as root: ``` docker exec -it audiobookshelf /bin/sh PID USER TIME COMMAND 1 root 0:00 npm start 18 root 0:07 node index.js 307 root 0:00 /bin/sh 315 root 0:00 ps aux ``` This is resulting in files being written as root on the host system, instead of them being written as the intended user: ``` ~/audiobookshelf/config/users/data$ ls -lhrt total 4.0K -rw-r--r-- 1 root root 0 Nov 28 09:40 data.2.json -rw-r--r-- 1 root root 1.2K Nov 28 09:40 data.4.json ```` ### Steps to reproduce the issue 1. Set up audiobookshelf using docker compose with the following env variables: AUDIOBOOKSHELF_UID=1000, AUDIOBOOKSHELF_GID=1000 2. Open a shell in the container 3. The process is running as root, not UID 1000 ### Audiobookshelf version v2.2.6 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:21:38 +02:00
adam closed this issue 2026-04-24 23:21:39 +02:00
Author
Owner

@hobesman commented on GitHub (Nov 28, 2022):

Currently the variables aren't used to set who it runs as, but instead they're used for setting permissions when creating certain files.

I (not being a dev myself) started to look into this at one point. What happens if you add:

user: 1000:1000

to the compose file? If you already have a config and metadata directory you may need to grant that user permissions for those locations. I'm just passing along what I read online somewhere though. I don't know if/what it would do for ABS.

@hobesman commented on GitHub (Nov 28, 2022): Currently the variables aren't used to set who it runs as, but instead they're used for setting permissions when creating certain files. I (not being a dev myself) started to look into this at one point. What happens if you add: user: 1000:1000 to the compose file? If you already have a config and metadata directory you may need to grant that user permissions for those locations. I'm just passing along what I read online somewhere though. I don't know if/what it would do for ABS.
Author
Owner

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

@hobesman is correct. Those env variables are just for Abs to use once the container is running.
The container owner is something you would need to set.
I'm not totally familiar with this part either since I just run mine as root but I also saw you can pass a user variable.

As far as I know this isn't an issue with Abs so I'm going to close this issue but if you find a good solution you can help improve the docs for others.

@advplyr commented on GitHub (Nov 28, 2022): @hobesman is correct. Those env variables are just for Abs to use once the container is running. The container owner is something you would need to set. I'm not totally familiar with this part either since I just run mine as root but I also saw you can pass a `user` variable. As far as I know this isn't an issue with Abs so I'm going to close this issue but if you find a good solution you can help improve the docs for others.
Author
Owner

@freezeeedos commented on GitHub (Nov 28, 2022):

After adding user: 1000:1000 to the service definition in docker-compose, like so:

  audiobookshelf:
    container_name: audiobookshelf
    image: ghcr.io/advplyr/audiobookshelf:latest
    user: 1000:1000

The main process in the container is running as the node user:

docker exec -it audiobookshelf /bin/sh
/ $ ps aux
PID   USER     TIME  COMMAND
    1 node      0:00 npm start
   19 node      0:01 node index.js
   37 node      0:00 /bin/sh
   43 node      0:00 ps aux
/ $

If there had been no user with the GID 1000 in the image, I would have had to modify the Dockerfile to create my own

@freezeeedos commented on GitHub (Nov 28, 2022): After adding user: 1000:1000 to the service definition in docker-compose, like so: ``` audiobookshelf: container_name: audiobookshelf image: ghcr.io/advplyr/audiobookshelf:latest user: 1000:1000 ``` The main process in the container is running as the node user: ``` docker exec -it audiobookshelf /bin/sh / $ ps aux PID USER TIME COMMAND 1 node 0:00 npm start 19 node 0:01 node index.js 37 node 0:00 /bin/sh 43 node 0:00 ps aux / $ ``` If there had been no user with the GID 1000 in the image, I would have had to modify the Dockerfile to create my own
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#786