wodby / drupal-php

PHP docker container image for Drupal
https://wodby.com/stacks/drupal
MIT License
60 stars 81 forks source link

What determines the username when using exec sh #47

Closed jurgenhaas closed 6 years ago

jurgenhaas commented 6 years ago

Maybe not the right place to ask but I'm pulling my hair out on this and hope you can help me with it.

On my main desktop I'm using the wodby/drupal-php:7.0 image and when calling docker-compose exec php sh I'll get into the container as root. From what I read everywhere, this is supposed to be the default.

However, on two other hosts with the same setup (?), when executing shell into the same container, I always become the www-data user instead of root.

What drives that decision? Is it configured in the image, in the container, or is it some other configuration?

pprishchepa commented 6 years ago

Default user has been switched to www-data in https://github.com/wodby/php/releases/tag/3.0.0.

So

jurgenhaas commented 6 years ago

Isn't that the setting for the processes like php-fpm which get launched during build? I'm looking for the user account which is used when connecting to the container with exec sh. In fact, I could do it manually with docker-compose exec --user root php sh but I was wondering where docker gets the default from. Is that really from this change? And if so, is there a way I can overwrite that locally?

joaomcarlos commented 6 years ago

I'd like to know this too

csandanov commented 6 years ago

The default user in containers is root unless a different specified in Dockerfile's USER directive. Since 3.x we have www-data as default user, if you want to use root instead you should set PHP_FPM_USER and PHP_FPM_GROUP which are mandatory when running php-fpm process as root

jurgenhaas commented 6 years ago

Well, this is not about the usr that runs the php fpm process. It's about the user that is used for the shell session. And I do habe a host where the php fpm session is run by www-data and the shell user is root. On other hosts the shell is also run as www-data and I can't figure out why.

csandanov commented 6 years ago

Because since 3.x we set USER in dockerfile to www-data, it determies the default linux (shell) user and has nothing to do with php-fpm. Read dockerfile reference for more details.

jurgenhaas commented 6 years ago

OK, I can confirm this being reproducable. The issue came from the fact that I used the "same" images on multiple hosts with different behaviour. At least that's what it looked like. The images have been wodby/drupal-php:7.0 but what I didn't realize was that they had different versions. I haven't found a way to find out a way to see more detailed information about the images available.

Regarding the original problem I guess I have to use the option --user root then explicitly. Shouldn't be a big problem as I'm using shell aliases anyways.

csandanov commented 6 years ago

From our readme:

For better reliability we additionally release images with stability tags (wodby/drupal-php:7.1-X.X.X) which correspond to git tags. We strongly recommend using images only with stability tags.