[PR #4700] [CLOSED] feat(docker): Add PUID/PGID support for volume permissions #4319

Closed
opened 2026-04-25 00:19:16 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4700
Author: @Vylyne
Created: 9/26/2025
Status: Closed

Base: masterHead: master


📝 Commits (1)

  • a201582 feat(docker): Add PUID/PGID support for volume permissions

📊 Changes

2 files changed (+60 additions, -2 deletions)

View changed files

📝 Dockerfile (+9 -2)
docker-entrypoint.sh (+51 -0)

📄 Description

Brief summary

Introduces an entrypoint script and 'gosu' to allow users to specify Process User ID (PUID) and Process Group ID (PGID) via environment variables.

Which issue is fixed?

Fixes #4471

In-depth Description

Introduces an entrypoint script and 'gosu' to allow users to specify Process User ID (PUID) and Process Group ID (PGID) via environment variables.

This resolves permission errors encountered when binding host volumes into the container, as the entrypoint script now runs 'chown' on /config and /metadata as root before dropping privileges and running the application.

  • Adds 'gosu' dependency to the runtime stage.
  • Implements 'docker-entrypoint.sh' to handle user switching and permission fixing.
  • Updates ENTRYPOINT to use the wrapper script, passing CMD as arguments.

How have you tested this?

I built the container and I'm running it now with a non root user it had no issues working with the files when previously it did when I used the user: directive in my docker compose.

Build Results

docker build -t audiobookshelf/server:puid-fix .
[+] Building 0.4s (23/23) FINISHED
 => [internal] load build definition from Dockerfile
 => => transferring dockerfile: 2.10kB
 => [internal] load metadata for docker.io/library/node:20-alpine
 => [internal] load .dockerignore
 => => transferring context: 198B
 => [internal] load build context
 => => transferring context: 58.91kB
 => [build-server 1/7] FROM docker.io/library/node:20-alpine@sha256:eabac870db94f7342d6c33560d6613f188bbcf4bbe1f4eb47d5e2a08e1a37722
 => CACHED [stage-2 2/8] RUN apk add --no-cache --update   tzdata   ffmpeg   tini   gosu
 => CACHED [stage-2 3/8] WORKDIR /app
 => CACHED [build-client 2/5] WORKDIR /client
 => CACHED [build-client 3/5] COPY /client /client
 => CACHED [build-client 4/5] RUN npm ci && npm cache clean --force
 => CACHED [build-client 5/5] RUN npm run generate
 => CACHED [stage-2 4/8] COPY --from=build-client /client/dist /app/client/dist
 => CACHED [build-server 2/7] RUN apk add --no-cache --update   curl   make   python3   g++   unzip
 => CACHED [build-server 3/7] WORKDIR /server
 => CACHED [build-server 4/7] COPY index.js package* /server
 => CACHED [build-server 5/7] COPY /server /server/server
 => CACHED [build-server 6/7] RUN case "linux/amd64" in   "linux/amd64")   curl -L -o /tmp/library.zip "https://github.com/mikiher/nunic
 => CACHED [build-server 7/7] RUN npm ci --only=production
 => CACHED [stage-2 5/8] COPY --from=build-server /server /app
 => CACHED [stage-2 6/8] COPY --from=build-server /usr/local/lib/nusqlite3/libnusqlite3.so /usr/local/lib/nusqlite3/libnusqlite3.so
 => CACHED [stage-2 7/8] COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
 => CACHED [stage-2 8/8] RUN chmod +x /usr/local/bin/docker-entrypoint.sh
 => exporting to image
 => => exporting layers
 => => writing image sha256:57b26ab064340edc5aee2ce7c1b341e3a5bd67ffe197786c71c4ec4dc6b9385d
 => => naming to docker.io/audiobookshelf/server:puid-fix 

Docker Compose Example

name: audiobookshelf
services:
  app:
    container_name: audiobookshelf
    image: audiobookshelf/server:puid-fix
    environment:
      - PUID=568
      - PGID=568
    ports:
      - 13378:80
    volumes:
      - /data:/Data
      - ./metadata:/metadata
      - ./config:/config
    restart: unless-stopped

Screenshots

Not applicable.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/4700 **Author:** [@Vylyne](https://github.com/Vylyne) **Created:** 9/26/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`a201582`](https://github.com/advplyr/audiobookshelf/commit/a20158254f613ec316a4cb7eaa76798fa114446b) feat(docker): Add PUID/PGID support for volume permissions ### 📊 Changes **2 files changed** (+60 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+9 -2) ➕ `docker-entrypoint.sh` (+51 -0) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary Introduces an entrypoint script and 'gosu' to allow users to specify Process User ID (PUID) and Process Group ID (PGID) via environment variables. ## Which issue is fixed? Fixes #4471 ## In-depth Description Introduces an entrypoint script and 'gosu' to allow users to specify Process User ID (PUID) and Process Group ID (PGID) via environment variables. This resolves permission errors encountered when binding host volumes into the container, as the entrypoint script now runs 'chown' on /config and /metadata as root before dropping privileges and running the application. - Adds 'gosu' dependency to the runtime stage. - Implements 'docker-entrypoint.sh' to handle user switching and permission fixing. - Updates ENTRYPOINT to use the wrapper script, passing CMD as arguments. ## How have you tested this? I built the container and I'm running it now with a non root user it had no issues working with the files when previously it did when I used the user: directive in my docker compose. Build Results ```shell docker build -t audiobookshelf/server:puid-fix . [+] Building 0.4s (23/23) FINISHED => [internal] load build definition from Dockerfile => => transferring dockerfile: 2.10kB => [internal] load metadata for docker.io/library/node:20-alpine => [internal] load .dockerignore => => transferring context: 198B => [internal] load build context => => transferring context: 58.91kB => [build-server 1/7] FROM docker.io/library/node:20-alpine@sha256:eabac870db94f7342d6c33560d6613f188bbcf4bbe1f4eb47d5e2a08e1a37722 => CACHED [stage-2 2/8] RUN apk add --no-cache --update tzdata ffmpeg tini gosu => CACHED [stage-2 3/8] WORKDIR /app => CACHED [build-client 2/5] WORKDIR /client => CACHED [build-client 3/5] COPY /client /client => CACHED [build-client 4/5] RUN npm ci && npm cache clean --force => CACHED [build-client 5/5] RUN npm run generate => CACHED [stage-2 4/8] COPY --from=build-client /client/dist /app/client/dist => CACHED [build-server 2/7] RUN apk add --no-cache --update curl make python3 g++ unzip => CACHED [build-server 3/7] WORKDIR /server => CACHED [build-server 4/7] COPY index.js package* /server => CACHED [build-server 5/7] COPY /server /server/server => CACHED [build-server 6/7] RUN case "linux/amd64" in "linux/amd64") curl -L -o /tmp/library.zip "https://github.com/mikiher/nunic => CACHED [build-server 7/7] RUN npm ci --only=production => CACHED [stage-2 5/8] COPY --from=build-server /server /app => CACHED [stage-2 6/8] COPY --from=build-server /usr/local/lib/nusqlite3/libnusqlite3.so /usr/local/lib/nusqlite3/libnusqlite3.so => CACHED [stage-2 7/8] COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh => CACHED [stage-2 8/8] RUN chmod +x /usr/local/bin/docker-entrypoint.sh => exporting to image => => exporting layers => => writing image sha256:57b26ab064340edc5aee2ce7c1b341e3a5bd67ffe197786c71c4ec4dc6b9385d => => naming to docker.io/audiobookshelf/server:puid-fix ``` Docker Compose Example ```yaml name: audiobookshelf services: app: container_name: audiobookshelf image: audiobookshelf/server:puid-fix environment: - PUID=568 - PGID=568 ports: - 13378:80 volumes: - /data:/Data - ./metadata:/metadata - ./config:/config restart: unless-stopped ``` ## Screenshots Not applicable. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:16 +02:00
adam closed this issue 2026-04-25 00:19:16 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4319