-
Notifications
You must be signed in to change notification settings - Fork 4
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
PHP container doesn't have access to write to file system under Linux host #183
Comments
So, here's what I understand of this issue: We don't see this behavior on macOS because it's using a shared-filesystem driver which maps the users and permissions already. Under linux, the container runs "directly" on the mounted disk, with no such mapping. The file permissions seen inside the alpine container are literally the user IDs from the host system. As there is no We also don't see it in production, because our host machines have a user called Per https://github.com/humanmade/docker-wordpress-php/blob/master/Dockerfile#L155, we run the container as the www-data user. This means the It is possible to run the container like So, back to what we want to do here. In a docker-native environment, I think we want to run the PHP container as the current user, so it will always have access to write to the mounted volumes. Note: In #111 we specifically decided to limit the user of the container, so setting this to the current user on the host therefor might contradict that decision. |
cc @rmccue and @nathanielks if you have time for guidance here! |
My brain is mush, but I am working on working through this. On the surface, I think passing the UID and GID of the current user makes sense in Linux environments, but I want to verify this before I 👍 or 👎 . I'm wondering if it'll make a difference to php-fpm/nginx if the container user is different and I'm not sure of that at the moment. |
I need to go pencils down for this to simmer, but here are my notes so far. I see 2 options:
I don't have a clear path forward for either solution, so I'm going to let this simmer and see if y'all have any ideas, too. |
I think the second option is still viable. It would require us update the nginx container to also accept the current user's UID and change some expectations around how the socket file has permissions assigned. I'll see if I can dive into this a bit deeper. |
@joehoyle actually, this brings to mind if this is even something we should allow? Being able to write to the filesystem does not work in a multi-server context, so users shouldn't be doing this anyway. If they need to write to the filesystem, they need to be writing to a temporary directory instead of the webroot. Am I mistaken here? |
aha, for my own context:
|
Thankfully I think there's a simpler solution here. Instead of changing the user the containers themselves run as, I think we can get the current UID of the user and adjust the user here:
What do you think of that, @joehoyle ? This will allow us to keep the docker images as they are while allowing cli commands to perform their work as desired. |
@nathanielks ah yes that may well provide us everything we need. I was thinking we needed the whole container running as that user but infact I think just the wp-cli / exec commands would be enough. |
@joehoyle brilliant! |
@joehoyle is this something y'all are able to pick up? |
Yup |
Pass the current user's UID when running on linux, as the mounted volumes are _directly_ accessed from the container. Unlike macOs, where the mounted volumes are is a Docker shared filesystem that correctly maps user permissions. Fixes #183.
I pushed a fix for this in #211, but I didn't try it out under Linux yet. |
Pass the current user's UID when running on linux, as the mounted volumes are _directly_ accessed from the container. Unlike macOs, where the mounted volumes are is a Docker shared filesystem that correctly maps user permissions. Fixes #183.
Released in 4.0.4 |
ls -la
in/usr/src/app
shows1000
as the user (ID), should be www-data.The text was updated successfully, but these errors were encountered: