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

docker: Allowing to downgrade to regular user via environment variables #89

Merged
merged 2 commits into from Feb 25, 2023

Conversation

tuxuser
Copy link
Contributor

@tuxuser tuxuser commented Feb 25, 2023

This change implements an entrypoint-script for the docker container.

By passing environment variables PUID=<numeric user id> and PGID=<numeric group id> to the container, which is started as root by the docker daemon, can downgrade to the respective user and run the stump server daemon with lower privileges.

This also ensures that mounted directories/volumes are assigned and accessed with proper permissions.

NOTE: This essentially breaks the invocation via --user argument, currently documented on Docker hub

Example docker compose

version: '3.3'
services:
  stump:
    image: aaronleopold/stump-preview:latest
    container_name: stump
    volumes:
      - /home/user/.stump-config:/config
      - /media/books:/data
    ports:
      - 10801:10801
    environment:
      - PUID=1000
      - PGID=1000
    restart: unless-stopped

or via CLI

docker create \
  --name=stump \
  -e "PUID=1000" \
  -e "PGID=1000" \
  -p 6969:6969 \
  --mount type=bind,source=/Users/aaronleopold/.stump,target=/config \
  --mount type=bind,source=/Users/aaronleopold/Documents/Stump,target=/data \
  --restart unless-stopped \
  aaronleopold/stump-preview

@aaronleopold
Copy link
Collaborator

Thanks so much, @tuxuser! I only had one comment, it looks great otherwise! I'm building an image now and can report back one I test it out

Relative path as seen from repo-root

Co-authored-by: Aaron Leopold <36278431+aaronleopold@users.noreply.github.com>
@aaronleopold
Copy link
Collaborator

All looks good! I'll merge this tomorrow 🚀

image

@aaronleopold aaronleopold marked this pull request as ready for review February 25, 2023 01:49
@aaronleopold aaronleopold merged commit da20577 into stumpapp:develop Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants