Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wtanksleyjr opened this issue Mar 8, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@wtanksleyjr
Copy link

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

@wtanksleyjr wtanksleyjr added the bug Something isn't working label Mar 8, 2022
@jacostag
Copy link

jacostag commented Mar 9, 2022

I can confirm

@DocBrown101
Copy link

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

@advplyr
Copy link
Owner

advplyr commented 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

@DocBrown101
Copy link

DocBrown101 commented 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:

@advplyr
Copy link
Owner

advplyr commented Mar 13, 2022

chown on the volumes?

@DocBrown101
Copy link

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

@advplyr
Copy link
Owner

advplyr commented Mar 13, 2022

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

@DocBrown101
Copy link

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.

@advplyr
Copy link
Owner

advplyr commented Mar 13, 2022

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

@DocBrown101
Copy link

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

@DocBrown101
Copy link

FYI: moby/moby#3124 (comment)

@DocBrown101
Copy link

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

@advplyr
Copy link
Owner

advplyr commented 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 added a commit that referenced this issue Apr 25, 2022
…ing intitial config/metadata directories at startup then set owner of those #394
@advplyr
Copy link
Owner

advplyr commented Apr 25, 2022

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

@advplyr advplyr closed this as completed Apr 25, 2022
selfhost-alt pushed a commit to selfhost-alt/audiobookshelf that referenced this issue May 31, 2022
…ing intitial config/metadata directories at startup then set owner of those advplyr#394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants