jboesl / docker-logitechmediaserver

Docker image for Logitech Media Server (lms, SqueezeCenter, SqueezeboxServer, SlimServer).
MIT License
6 stars 6 forks source link

REQUEST - make user and group for process configurable #4

Closed bfg100k closed 4 years ago

bfg100k commented 4 years ago

Your current docker config requires modifying the volume permissions to a static value (i.e. must be 101:65534). A more flexible way to do is is pass them in via ENV parameters. Right now, there is a trend of using PUID and PGID (https://docs.linuxserver.io/general/understanding-puid-and-pgid). Here's a sample snippet of code (from apnar) on how to implement. Will be great if you can incorporate this into your future release. Thanks!

----------------- using entrypoint.sh script ----------------------------------

!/bin/sh

umask 0002 PUID=${PUID:-id -u squeezeboxserver} PGID=${PGID:-id -g squeezeboxserver}

groupmod -o -g "$PGID" nogroup usermod -o -u "$PUID" squeezeboxserver

umask 0002 exec squeezeboxserver --user squeezeboxserver --group nogroup \ --prefsdir /config/prefs \ --logdir /config/logs \ --cachedir /config/cache "$@"

jboesl commented 4 years ago

Looks good. I was thinking about fixing that, too, since that's not how a container should behave. I'll include it as soon as possible.

bfg100k commented 4 years ago

Thanks for adding this feature. However, I can't seem to get it to work on my box. I'm getting the following error:

usermod: user squeezeboxserver is currently used by process 1 groupmod: Permission denied. groupmod: cannot lock /etc/group; try again later.

The ids I tried to use are below and I've made sure that the host directory is owned by these ids -e PUID=1033 -e PGID=65538

bfg100k commented 4 years ago

In fact, when I run the container without changing the ids, I am seeing the following in the logs

usermod: invalid user ID 'id -u squeezeboxserver' groupmod: invalid group ID 'id -g nogroup'

Although the service starts up fine after...