subdavis / kobo-book-downloader

A tool to download and remove DRM from your purchased Kobo.com ebooks and audiobooks.
https://pypi.org/project/kobodl/
The Unlicense
348 stars 33 forks source link

Docker add user permission denied #102

Closed mslmn closed 10 months ago

mslmn commented 1 year ago

Describe the issue I have managed to get kobodl running on my M1 Mac via docker. However, when I try to add a user I get this error:

Traceback (most recent call last):
  File "/opt/kobodl/local/venv/bin/kobodl", line 5, in <module>
    cli()
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/kobodl/local/venv/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/opt/kobodl/src/kobodl/commands/user.py", line 80, in add
    actions.Login(user, password, captcha)
  File "/opt/kobodl/src/kobodl/actions.py", line 167, in Login
    kobo.AuthenticateDevice()
  File "/opt/kobodl/src/kobodl/kobo.py", line 334, in AuthenticateDevice
    Globals.Settings.Save()
  File "/opt/kobodl/src/kobodl/settings.py", line 62, in Save
    with open(self.SettingsFilePath, "w") as f:
PermissionError: [Errno 13] Permission denied: '/kobodl.json'

To Reproduce Steps to reproduce the behavior: this is my docker-compose file:

version: '3.8'
services:
  kobodl:
    image: ghcr.io/subdavis/kobodl:latest
    build:
      context: .
      dockerfile: Dockerfile
    container_name: kobodl
    restart: unless-stopped
    user: ${PUID:-1000}
    ports:
      - "6666:6666"
    volumes:
      # These mappings will be the same for command line and web server
      - /Users/temp/kobodl/downloads:/home/downloads
      - /Users/temp/kobodl/config:/home/config
    command: --config /home/config/kobodl.json serve -h 0.0.0.0 -p 6666 --output-dir /home/downloads

I ran the add user command with --captcha "" to circumvent the Pyperclip could not find a copy/paste mechanism for your system. issue.

Expected behavior Successful user addition

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

subdavis commented 1 year ago

Try the version from the documentation.

https://github.com/subdavis/kobo-book-downloader#docker

SerujiShard commented 1 year ago

I have the same issue, I'm using Portainer, using the WebUI it gives me the following error when trying to add a user:

Error! [Errno 13] Permission denied: '/home/config/kobodl.json'

My compose file looks like the following:

version: '3'
services:
  kobodl_http_server:
    container_name: kobodl
    image: ghcr.io/subdavis/kobodl
    command: >
      serve --host 0.0.0.0 --output-dir /home/downloads/kobodl_downloads
    ports:
      - "4000:5000"
    volumes:
      - /docker/kobodl/config:/home/config
      - /drives/mediaserver/Audiobooks:/home/downloads
    user: "3000:3000"

I also tried to do the same command that there is in the documentation to check if it was an issue of my compose file but I get the same error. I also tried to import the kobodl.json file from my Windows PC (where kobodl has been always working flawlessly) but no luck either, thanks in advance for the assistance!

subdavis commented 1 year ago

Looks like you're trying to access /docker/kobodl/config on your host system as user 3000, which you don't have permissions for.

@SerujiShard please try this instead, without modifying, in a directory you have full write access to.

docker run --rm -it --user $(id -u):$(id -g) \
  -p 4000:5000 \
  -v ${HOME}/.config:/home/config \
  -v ${PWD}:/home/downloads \
  ghcr.io/subdavis/kobodl \
  --config /home/config/kobodl.json \
  serve \
  --host 0.0.0.0 \
  --output-dir /home/downloads/kobodl_downloads
mslmn commented 10 months ago

This runs great, but since I'm on an M1 Mac I had to add --platform linux/amd64 after docker run.