Uh oh!
There was an error while loading. Please reload this page.
Change uid of www-data user before starting apache - #286
Conversation
Vampouille
commented
Aug 8, 2016
I don't known if there is a way to split long entrypoint line with json format. |
ihor-sviziev
commented
Aug 15, 2016
@Vampouille I think we should create separate sh file for entrypoint. |
Vampouille
commented
Aug 17, 2016
@ihor-sviziev I just updated my PR with a dedicated shell script. I also check if UID need to be changed. |
ihor-sviziev
commented
Aug 17, 2016
I think apache2-foreground should be moved to CMD in Dockerfile. In general it looks very good for me! |
Vampouille
commented
Aug 17, 2016
I move |
Vampouille
commented
Aug 17, 2016
Can I run |
Vampouille
commented
Aug 22, 2016
Vampouille
commented
Sep 2, 2016
@tianon Do you think this PR have a chance to be merged ? |
tianon
commented
Sep 2, 2016
I'm not comfortable with the PHP image doing With #282 (and #291), changing the runtime user should be possible with $ docker run -dit --name apache-nobody -e APACHE_RUN_USER=nobody php:7.0-apache763df5c2d7012678a270d7ef021919323c12e87b4471ed52755164b7e833440e
$ docker logs apache-nobodyAH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this messageAH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message[Fri Sep 02 16:45:34.496215 2016] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.0.10 configured -- resuming normal operations[Fri Sep 02 16:45:34.496233 2016] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
$ docker top apache-nobodyUID PID PPID C STIME TTY TIME CMDroot 29375 29361 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUNDnobody 29406 29375 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUNDnobody 29407 29375 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUNDnobody 29408 29375 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUNDnobody 29409 29375 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUNDnobody 29410 29375 0 09:45 pts/9 00:00:00 apache2 -DFOREGROUND |
Thanks for your answer, the purpose of this PR is to be able to run apache with numeric uid 999. It seems that 999 as uid is common across docker images. You can look at postgres official images : In docker env, when you share some named volumes, textual username is not used. Docker does not make translation or mapping between user of containers. So files owners are only identify by numeric value. If I try to launch apache with uid 999, it complains about not finding user with uid 999 :
In my PR, |
Vampouille
commented
Sep 5, 2016
https://github.com/docker-library/php/pull/286/files#diff-8874cb4a06e835f8683c251ffad0fb3fR11 I think that |
| WANTED_UID=${RUN_AS_UID:-33} | ||
| # check if UID need to be updated | ||
| if [ $CURRENT_UID -ne $WANTED_UID ]; then |
There was a problem hiding this comment.
I tried using this same code in a different docker image to change the www-data UID and needed to tweak this line to if [ "$CURRENT_UID" -ne "$WANTED_UID" ]; then, and the above to WANTED_UID=${RUN_AS_UID}
There was a problem hiding this comment.
CURRENT_UID and WANTED_UID should not be empty because :
idcommand always return numeric identifier${RUN_AS_UID:-33}use 33 as default value ifRUN_AS_UIDis not set
Can you explain steps to reproduce your issue, maybe your www-data default uid was not set to 33.
There was a problem hiding this comment.
@Vampouille that makes sense.. I'm not clear why the ID was not set by default on my instance, but based on what you're saying it doesn't seem like this change needs to be made. Thanks for taking the time to respond!
tianon
commented
Apr 5, 2017
Beyond the solution of
This is adaptable to use users other than $ docker run -it --rm -u 999 87926a4f33dcAH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.16. Set the 'ServerName' directive globally to suppress this messageAH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.16. Set the 'ServerName' directive globally to suppress this message[Wed Apr 05 21:09:22.110035 2017] [core:error] [pid 1] (13)Permission denied: AH00099: could not create /var/run/apache2/apache2.pid[Wed Apr 05 21:09:22.110068 2017] [core:error] [pid 1] AH00100: apache2: could not log pid to file /var/run/apache2/apache2.pidThanks for the contribution and discussion! ❤️ |
This PR is a proposal to fix#14 with use of
usermodcommand.This PR replace entrypoint with 3 commands :
usermodon www-data to change uid with value of RUN_AS_UID env variablechownon directory previously owned by www-dataapache2-foreground