mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-02 22:46:55 -05:00
[Enhancement]: Run container as user with environmental variable #2315
Labels
No labels
authentication
awaiting release
backlog
bug
chapter editor
config-issue
ebooks
encoding/embedding
enhancement
help wanted
listening sessions & progress
planned
possible plugin
progress sync
sorting/filtering/searching
unable to reproduce
upload
users & permissions
waiting
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/audiobookshelf-advplyr#2315
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @1alexhurts on GitHub (Oct 16, 2024).
Type of Enhancement
Server Backend
Describe the Feature/Enhancement
check for PUID GUID environmental variable on starting the container, and run as that user
Why would this be helpful?
Permissions! They're a pain and this is helpful. The linuxserver containers are beloved and this is part of why
Future Implementation (Screenshot)
I thought something like this in the dockerfile/image could work, but the container couldn't run su-exec and I couldn't figure out how to install it. I don't know what I'm doing
#!/bin/sh
if [ -n "$PUID" ] && [ -n "$PGID" ]; then
echo "Starting as UID: $PUID, GID: $PGID"
else
echo "Starting as root"
exec "$@"
fi
Audiobookshelf Server Version
2.15.0
Current Implementation (Screenshot)
Container details in portainer
@nichwall commented on GitHub (Oct 16, 2024):
ABS does not use
PUIDorGUID. You should use theuserdirective because this is supported by docker itself instead of requiring individual containers to correctly usePUIDorGUID. An example below (edited due to typo):@advplyr commented on GitHub (Oct 16, 2024):
I think someone mentioned that linuxserver started doing that before docker had made available
user. I'm not sure if that's true but I don't see the benefit of adding environment variables when there isuserbuilt-in.@1alexhurts commented on GitHub (Oct 18, 2024):
Some containers need to do root stuff at startup and then switch to a user,
I believe that's why. Again, I'm a beginner I may be missing something. My
reverse proxy is an example, putting it in the docker compose like your
example doesn't work, it won't start. They built in at a certain point to
switch user with a variable.
Environmental variables makes it easy and more consistent container to
container, which is the benefit of using linuxserver containers and why
I've made the request
On Wed, Oct 16, 2024 at 5:50 PM advplyr @.***> wrote:
@cw1 commented on GitHub (Dec 20, 2024):
@nichwall : I've tested your docker-compose, but audiobookshelf doesn't start because it's missing to permission to open port 80 inside the container. You need to add the environment variable
PORTand set it to an unprivileged port (>1024).BTW: I couldn't find the
PORTvariable in the documentation and needed to look atindex.jsto find out. But that's maybe more of a documentation issue.@lhanson commented on GitHub (Jan 11, 2025):
Came here looking for something similar. I could not get the container to start as documented because it was trying to open port 80. The undocumented
PORTvariable is what I was looking for.@nichwall commented on GitHub (Jan 12, 2025):
Environment variables are documented on the ABS website.
https://www.audiobookshelf.org/docs#network
@matru commented on GitHub (Jan 26, 2025):
@lhanson @cw1 so that means port 3333 is what we can use as an alternative?
Update: So it turns out that when using the --user option, you can't really use port 80, actually you cannot use any of the privileged TCP/UDP ports below 1024. Since
PORTenv changes the container port, we specify something that isn't in that range of below 1024, it does not need to be 3333 and I think the developer just uses that locally? Not sure. Anyways I run it on a completely different port now, but one that is not in the range <1024, by specifying it thePORTenv variable, and it works fine. Be sure to also specify the port to docker, example:@jkjustjoshing commented on GitHub (Feb 25, 2025):
Make sure that the volumes are for the correct user. I used the
PORT>1024method but the container still wouldn't start. I shut down the container,chown'd all the volume directories, and restarted the container and everything worked.