-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conform to the Docker standard #2028
Comments
Funny you say that as I only came to this unofficial docker image because there were problems with the NextCloud-AIO official - with problems along those lines (ownership/root/UID). But this repo/image worked at least. Fixing the other seemed beyond me for the minute. |
Hi @dk-zero-cool - See #1812 (though it doesn't appear to have made it into the docs - oops). Re: PUID/GUID: There is no standard I'm aware of (feel free to provide a reference). There are some container maintainers (@linuxserver comes to mind) that use these variables - e.g. https://docs.linuxserver.io/general/understanding-puid-and-pgid - but that's all.
I assume you are referring to - and using - bind mounts rather than volumes. This is not an issue at all when using volumes for persistent data. This issue arises with bind mounts because the filesystem ends up being shared with the host and not at all managed by Docker. Both, however, are persistent data stores and not at all limited to "small closed containers". https://docs.docker.com/storage/volumes/ |
Yes I am talking about bind-mounts. NextCloud is used to synchronize personal data between devices, and as such will in many cases not be confined just to a random volume on the server. In my case I have NFS setup via autofs to a server running a ZFS Raid configuration that is used to store everything, not just the data being shared with NextCloud. Using And yes, apparently this is not an official Docker standard, but a lot of, and not just some, maintainers do conform to it. |
Is there a solution for that ? |
Has there ever been found a solution to this? I think my issue is related: #2179 |
There is always the option, until this is addressed, to change the entrypoint manually. Now I did change this after I created this issue, because the group and user is exported before entrypoint is executed. So all you need to do is change the variables. init.sh #!/bin/bash
PUNAME=nc_puid
PGNAME=nc_pgid
##
# Create the user and group
if grep -qE "^([^:]+:){2}$PGID:" /etc/group; then
# Group already exists with another name
PGNAME=$(grep -qE "^([^:]+:){2}$PGID:" /etc/group | awk -F: '{print $1}')
else
groupadd --gid $PGID $PGNAME &>/dev/null
fi
if grep -qE "^([^:]+:){2}$PUID:" /etc/passwd; then
# User already exists with another name
PUNAME=$(grep -qE "^([^:]+:){2}$PUID:" /etc/passwd | awk -F: '{print $1}')
else
useradd --uid $PUID --gid $PGID $PUNAME --system &>/dev/null
fi
##
# Force Apache (thereby Nextcloud) to run as the custom user and group
export APACHE_RUN_USER=$PUNAME
export APACHE_RUN_GROUP=$PGNAME
##
# Execute the original entrypoint script and launch Nextcloud
/entrypoint.sh "$@" Now just add this file to your instance and change the entrypoint. docker create \
--env PUID=1000
--env PGID=1000
--volume $TARGET/init.sh:/init.sh
--entrypoint /init.sh
... After that your Nextcloud instance will run as your defined user and create files and directories with the prefered ownership. |
Hi.
Docker has to standard environment variables
PUID
andGUID
. These are meant to be used to allow one to select the user and group for the containers main process. This is a great help when you share volumes with a container that has specific user/group permissions. However this is not being used by the NextCloud docker image for some reason and I had to make an entrypoint wrapper to fix it on my setup.Using the
www-data
user may be fine for a small closed container, but it really is not very useful when sharing volumes with the host.The text was updated successfully, but these errors were encountered: