by275 / plex_autoscan

A maintained fork of Plex Autoscan
GNU General Public License v3.0
13 stars 2 forks source link

Do we need to mount the Plex database into the plex_autoscan container? #33

Closed CLHatch closed 1 year ago

CLHatch commented 1 year ago

I was setting up the plex_autoscan Docker container, basing the settings on an old config I had from a combined plex/plex_autoscan container (which used the original version of plex_autoscan). That old container I used had Plex and plex_autoscan in the same container, so of course all files were locally accessible.

While setting up your container, I managed to get everything apparently set up, and it apparently was able to see the Plex libraries through Docker (I believe I had to add a mount to the docker.sock file). But it was also spamming the logs with this:

2023/09/17 23:59:55 ERROR MAIN [MainThr] Unable to locate Plex DB file: PLEX_DATABASE_PATH=/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db

I just now got rid of that error by mounting the Plex library into the plex_autoscan container, but now the error is replaced with:

2023/09/18 00:31:33 ERROR UTILS  [MainThr] Process terminated with exit code: 1
WARNING: Error loading config file: /root/.docker/config.json: open /root/.docker/config.json: permission denied
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/plex/json": dial unix /var/run/docker.sock: connect: permission denied
2023/09/18 00:31:33 ERROR MAIN   [MainThr] Unable to run 'Plex Media Scanner' binary. Check your config again.
2023/09/18 00:31:35 ERROR UTILS  [MainThr] Process terminated with exit code: 1
WARNING: Error loading config file: /root/.docker/config.json: open /root/.docker/config.json: permission denied
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/plex/json": dial unix /var/run/docker.sock: connect: permission denied
2023/09/18 00:31:35 ERROR MAIN   [MainThr] Unable to run 'Plex Media Scanner' binary. Check your config again.
2023/09/18 00:31:37 ERROR UTILS  [MainThr] Process terminated with exit code: 1
WARNING: Error loading config file: /root/.docker/config.json: open /root/.docker/config.json: permission denied
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/plex/json": dial unix /var/run/docker.sock: connect: permission denied

This is my current compose for your container:

  plex_autoscan:
    image: ghcr.io/by275/autoscan:latest
    hostname: ${DOCKERHOSTNAME}
    container_name: plex_autoscan
    ports:
      - ${PLEXAUTOSCAN_PORT_3467}:3467
    environment:
      - PGID=${PGID}
      - PUID=${PUID}
      - UMASK=${UMASK}
      - TZ=${TZ}
    logging:
      driver: json-file
      options:
        max-file: ${DOCKERLOGGING_MAXFILE}
        max-size: ${DOCKERLOGGING_MAXSIZE}
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERCONFDIR}/plex_autoscan:/config
      - ${DOCKERCONFDIR}/plex/Library:/config/Library:ro
      - ${DOCKERSTORAGEDIR}:/storage
    depends_on:
      - plex

I feel there must be something simple I'm missing... Any help would be appreciated.

Edit: Even though I'm getting that error, this does work:

clhatch@dockstarter:~/.config/appdata/plex_autoscan$ docker exec -it plex_autoscan /bin/bash
root@DockSTARTer:/# autoscan sections+
  key  title         type      items  size    lang    locations
-----  ------------  ------  -------  ------  ------  -----------------------------
    3  Movies        movie      2512  9.83T   en-US   - /storage/media/Movies
                                                      - /storage/media/Movies4K
    2  TV Shows      show        993  39.97T  en-US   - /storage/media/TV4K
                                                      - /storage/media/TV
   13  Music         artist      428  0.05T   en      - /storage/media/Music
    4  Photos        photo         1  0.03T   en      - /storage/media/Pictures
    9  Home Videos   movie       197  0.04T   xn      - /storage/media/Home Videos
   10  Music Videos  movie       128  0.00T   xn      - /storage/media/Music Videos
    6  Tutorials     movie       646  0.06T   xn      - /storage/media/Tutorials
by275 commented 1 year ago

Yes you should make autoscan accessible to plex database file but error is nothing to do with it. There seems no permission to access docker.sock for user with $PUID:$PGID. How about doing something like this? usermod -aG docker <username>

CLHatch commented 1 year ago

Yes you should make autoscan accessible to plex database file but error is nothing to do with it. There seems no permission to access docker.sock for user with $PUID:$PGID. How about doing something like this? usermod -aG docker <username>

Makes sense. I believe your container uses user abc, so I created the docker group and added user abc to that group, then restarted for good measure. Unfortunately, still getting the permission issues.

by275 commented 1 year ago

Reproduced

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/pms/json": dial unix /var/run/docker.sock: connect: permission denied

and found the permission handling is missing https://github.com/sabrsorensen/alpine-plex_autoscan/blob/00eac031e74dd961242549451e135982fe0f1f66/root/etc/cont-init.d/10-init_user_and_fix_permissions#L52

It will be fixed soon.