Skip to content
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

alpine fpm image does not support running as a different user other than www-data #876

Closed
ghost opened this issue Aug 19, 2019 · 5 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@ghost
Copy link

ghost commented Aug 19, 2019

This has been mentioned (and evidenced) in #70 and #14, and the presence of hardcoded usernames already affected the apache images (see docker-library/wordpress#249).

Multiple longstanding issues exist, including some in the doc repo: docker-library/docs#1215 (comment). It seems the apache images are working now with this, although the fpm ones are not. This is unfortunate as the memory footprint of fpm is far lower, it is easier to isolate vs mod_php, and it does not create a en entire copy of the PHP interpreter and libraries in memory for every web server process.

I find it puzzling that the fpm images did not benefit from this first, as the ease of implementing this feature for them should be slightly more simple than it was for the apache counterparts.

@rcdailey has contributed quite a bit for this, AFAIK, but I don't see anything merged or working in the main repos.

See also nextcloud/docker#458 (comment)

@rcdailey
Copy link

rcdailey commented Aug 19, 2019 via email

@ghost
Copy link
Author

ghost commented Aug 19, 2019

  nextcloud-app:
    image: nextcloud:16-apache
    restart: unless-stopped
    user: $NEXTCLOUD_WEB_UID:$NEXTCLOUD_WEB_GID
    sysctls:
      - net.ipv4.ip_unprivileged_port_start=0
    environment:
      - MYSQL_HOST=nextcloud-db
      - APACHE_RUN_USER=#$NEXTCLOUD_WEB_UID
      - APACHE_RUN_GROUP=#$NEXTCLOUD_WEB_GID
      - NEXTCLOUD_DATA_DIR=/nextcloud-data
      - REDIS_HOST=nextcloud-redis
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=(...)
    env_file:
      - db.env
    volumes:
      - nextcloud-web:/var/www/html
      - nextcloud-data:/nextcloud-data
    ports:
      - 127.0.0.1:8082:80

No dice. Not sure fpm, it shouldn't be the case unless you chroot the fpm pool process.
Definitely not having a lucky strike with the docker composer files for nextcloud.

Also seeing this:

nextcloud-app_1    | Configuring Redis as session handler
nextcloud-app_1    | /entrypoint.sh: 26: /entrypoint.sh: cannot create /usr/local/etc/php/conf.d/redis-session.ini: Permission denied
nextcloud-app_1    | Initializing nextcloud 16.0.4.1 ...
nextcloud-db_1     | Initializing database

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Aug 19, 2019
@wglambert
Copy link

the presence of hardcoded usernames already affected the apache images

The image doesn't have any hardcoded username, running Apache as an arbitrary user works fine

$ docker run -d --name apache --sysctl net.ipv4.ip_unprivileged_port_start=0 --user 1000:1000 -e APACHE_RUN_USER=#1000 php:apache
0a355e9479346a0e5a3ef6738091960f5f09f94e4819565032bf707252ec6e41

$ docker exec apache ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
1000         1  4.1  0.2  82920 24792 ?        Ss   17:21   0:00 apache2 -DFOREGROUND
1000        16  0.0  0.0  82944  5004 ?        S    17:21   0:00 apache2 -DFOREGROUND
1000        17  0.0  0.0  82944  5004 ?        S    17:21   0:00 apache2 -DFOREGROUND
1000        18  0.0  0.0  82944  5004 ?        S    17:21   0:00 apache2 -DFOREGROUND
1000        19  0.0  0.0  82944  5004 ?        S    17:21   0:00 apache2 -DFOREGROUND
1000        20  0.0  0.0  82944  5004 ?        S    17:21   0:00 apache2 -DFOREGROUND
1000        21  0.0  0.0   7640  2756 ?        Rs   17:21   0:00 ps aux

Your issue is with an image we don't maintain ourselves, but php:fpm-alpine is able to run as an arbitrary user

$ docker run -d --rm --user 1000:1000 --name php php:fpm-alpine
d16815859f8d036cab4af0a7e5ad416fe319b7200c2467e705e248b04379319e

$ docker exec php ps aux
PID   USER     TIME  COMMAND
    1 1000      0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
    6 1000      0:00 php-fpm: pool www
    7 1000      0:00 php-fpm: pool www
    8 1000      0:00 ps aux

@wglambert
Copy link

Your issue is a duplicate of nextcloud/docker#763

/usr/local/etc/php/conf.d/redis-session.ini can not be written when using a non-root image, because the folder is owned by root and the default www-data user does not have write permission.

@yosifkit
Copy link
Member

Closing since this is an issue in the nextcloud image and not php:fpm-alpine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

3 participants