[Bug]: Docker creates cover.jpg as root instead of using AUDIOBOOKSHELF_UID #223

Closed
opened 2026-04-24 23:01:35 +02:00 by adam · 14 comments
Owner

Originally created by @wtanksleyjr on GitHub (Mar 8, 2022).

Describe the issue

I found that when using docker-compose with an env of AUDIOBOOKSHELF_UID:AUDIOBOOKSHELF_GID as 1000:1000, although other files are created fine, cover.jpg is created owned by root.

Steps to reproduce the issue

  1. I edited my docker-compose.yml to add the AUDIOBOOKSHELF_UID=1000 (Ubuntu main user account)
  2. I then logged in as 'root', configured to keep metadata and cover image in the book folder
  3. triggered a Match on a book I'd not matched before.
  4. Check that the metadata.abs file is created correctly, but cover.jpg is owned by root.

Audiobookshelf version

v1.7.2

How are you running audiobookshelf?

Docker

Originally created by @wtanksleyjr on GitHub (Mar 8, 2022). ### Describe the issue I found that when using docker-compose with an env of AUDIOBOOKSHELF_UID:AUDIOBOOKSHELF_GID as 1000:1000, although other files are created fine, `cover.jpg` is created owned by `root`. ### Steps to reproduce the issue 1. I edited my docker-compose.yml to add the AUDIOBOOKSHELF_UID=1000 (Ubuntu main user account) 2. I then logged in as 'root', configured to keep metadata and cover image in the book folder 3. triggered a Match on a book I'd not matched before. 4. Check that the `metadata.abs` file is created correctly, but `cover.jpg` is owned by root. ### Audiobookshelf version v1.7.2 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:01:35 +02:00
adam closed this issue 2026-04-24 23:01:36 +02:00
Author
Owner

@jacostag commented on GitHub (Mar 9, 2022):

I can confirm

@jacostag commented on GitHub (Mar 9, 2022): I can confirm
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

When I manually set the user in the docker-compose file, I get an error on startup that the required directories cannot be created, even though I am using volumes.

user: 1000:1000

@DocBrown101 commented on GitHub (Mar 13, 2022): When I manually set the user in the docker-compose file, I get an error on startup that the required directories cannot be created, even though I am using volumes. `user: 1000:1000`
Author
Owner

@advplyr commented on GitHub (Mar 13, 2022):

When I manually set the user in the docker-compose file, I get an error on startup that the required directories cannot be created, even though I am using volumes.

user: 1000:1000

Can you share your full docker compose

@advplyr commented on GitHub (Mar 13, 2022): > When I manually set the user in the docker-compose file, I get an error on startup that the required directories cannot be created, even though I am using volumes. > > `user: 1000:1000` Can you share your full docker compose
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

version: '2.4'
services:
  audiobookshelf:
    image: advplyr/audiobookshelf:1.7.2
    container_name: P-audiobookshelf
    restart: on-failure:5
    ports:
      - 192.168.0.220:8187:80
    user: 1000:1000
    environment:
      - AUDIOBOOKSHELF_UID=1000
      - AUDIOBOOKSHELF_GID=1000
    security_opt:
      - apparmor:docker-default
      - no-new-privileges
    cpu_shares: 100
    pids_limit: 100
    mem_limit: 200m
    read_only: true
    volumes:
      - audiobooks:/audiobooks
      - metadata:/metadata
      - config:/config
      # Use the same time zone as the host machine.
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

volumes:
  audiobooks:
  metadata:
  config:
@DocBrown101 commented on GitHub (Mar 13, 2022): ```yaml version: '2.4' services: audiobookshelf: image: advplyr/audiobookshelf:1.7.2 container_name: P-audiobookshelf restart: on-failure:5 ports: - 192.168.0.220:8187:80 user: 1000:1000 environment: - AUDIOBOOKSHELF_UID=1000 - AUDIOBOOKSHELF_GID=1000 security_opt: - apparmor:docker-default - no-new-privileges cpu_shares: 100 pids_limit: 100 mem_limit: 200m read_only: true volumes: - audiobooks:/audiobooks - metadata:/metadata - config:/config # Use the same time zone as the host machine. - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro volumes: audiobooks: metadata: config: ```
Author
Owner

@advplyr commented on GitHub (Mar 13, 2022):

chown on the volumes?

@advplyr commented on GitHub (Mar 13, 2022): chown on the volumes?
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

I have the volumes created automatically or what exactly do you mean?

@DocBrown101 commented on GitHub (Mar 13, 2022): I have the volumes created automatically or what exactly do you mean?
Author
Owner

@advplyr commented on GitHub (Mar 13, 2022):

Oh, those volumes don't already exist?
Can you share the exact error log?

@advplyr commented on GitHub (Mar 13, 2022): Oh, those volumes don't already exist? Can you share the exact error log?
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

They do not exist because I deleted them before.
Here is the error log:

audiobookshelf@1.7.2 start /
node index.js

Config /config /metadata /audiobooks
/node_modules/njodb/index.js:103
throw error;

Error: EACCES: permission denied, mkdir '/config/audiobooks'
at mkdirSync (fs.js:921:3)
at new Database (/node_modules/njodb/index.js:121:48)
at new Db (/server/Db.js:24:25)
at new Server (/server/Server.js:54:15)
at Object. (/index.js:27:16)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/config/audiobooks'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! audiobookshelf@1.7.2 start: node index.js
npm ERR! Exit status 7

npm ERR! Failed at the audiobookshelf@1.7.2 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@DocBrown101 commented on GitHub (Mar 13, 2022): They do not exist because I deleted them before. Here is the error log: > audiobookshelf@1.7.2 start / > node index.js Config /config /metadata /audiobooks /node_modules/njodb/index.js:103 throw error; Error: EACCES: permission denied, mkdir '/config/audiobooks' at mkdirSync (fs.js:921:3) at new Database (/node_modules/njodb/index.js:121:48) at new Db (/server/Db.js:24:25) at new Server (/server/Server.js:54:15) at Object.<anonymous> (/index.js:27:16) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) { errno: -13, syscall: 'mkdir', code: 'EACCES', path: '/config/audiobooks' } npm ERR! code ELIFECYCLE npm ERR! errno 7 npm ERR! audiobookshelf@1.7.2 start: `node index.js` npm ERR! Exit status 7 npm ERR! Failed at the audiobookshelf@1.7.2 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Author
Owner

@advplyr commented on GitHub (Mar 13, 2022):

It's creating that /config dir then, can you check the owner of that dir?

@advplyr commented on GitHub (Mar 13, 2022): It's creating that /config dir then, can you check the owner of that dir?
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

As far as I can see it is "root" :(
But I don't understand why, these volumes are new created after all.

@DocBrown101 commented on GitHub (Mar 13, 2022): As far as I can see it is "root" :( But I don't understand why, these volumes are new created after all.
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

FYI: https://github.com/moby/moby/issues/3124#issuecomment-104937065

@DocBrown101 commented on GitHub (Mar 13, 2022): FYI: https://github.com/moby/moby/issues/3124#issuecomment-104937065
Author
Owner

@DocBrown101 commented on GitHub (Mar 13, 2022):

I have now created my own directory with userid 1000 and used that instead of the volumes. Now it works!

@DocBrown101 commented on GitHub (Mar 13, 2022): I have now created my own directory with userid 1000 and used that instead of the volumes. Now it works!
Author
Owner

@advplyr commented on GitHub (Mar 13, 2022):

Oh okay so I guess the server should be setting the owner of those initial directories to the UID/GID passed in env.

@advplyr commented on GitHub (Mar 13, 2022): Oh okay so I guess the server should be setting the owner of those initial directories to the UID/GID passed in env.
Author
Owner

@advplyr commented on GitHub (Apr 25, 2022):

Initial directories and downloaded/uploaded covers will be getting the proper permissions and owners set now in v2.0.3

@advplyr commented on GitHub (Apr 25, 2022): Initial directories and downloaded/uploaded covers will be getting the proper permissions and owners set now in [v2.0.3](https://github.com/advplyr/audiobookshelf/releases/tag/v2.0.3)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#223