httpd and php-fpm dockerfile, unable to run php-fpm with non-root user

  apache, docker, dockerfile, httpd.conf, php

Motto is to run docker container with non-root user & got stuck at php-fpm error.
unable to figure out the issue…

NOTICE: [pool www] ‘user’ directive is ignored when FPM is not running as root

NOTICE: [pool www] ‘group’ directive is ignored when FPM is not running as root

The problem is its giving same error, even though i changed configuration files with another user name.
I’ve already edited the www.conf config at /etc/php-fpm.d/www.conf with:

[www]
user = www-data
group = www-data

listen = /var/run/www.sock

listen.owner = www-data
listen.group = www-data
listen.mode = 0660
;listen.acl_users = apache,nginx

i also edited httpd.conf configuration /etc/httpd/conf/httpd.conf

Listen 8080
User www-data
Group www-data

The Dockerfile which includes all the process of installation, i used different user to execute httpd and php-fpm.
Here httpd is running with non-root i.e. www-data, however php-fpm is not running with non-root.
It is giving error as

NOTICE: [pool www] ‘user’ directive is ignored when FPM is not running as root

NOTICE: [pool www] ‘group’ directive is ignored when FPM is not running as root

FROM amazonlinux:latest
MAINTAINER ********
RUN yum update -y
RUN amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
RUN yum install -y httpd sudo
RUN yum install -y php-mbstring php-gd php-pecl-zip php-pdo
COPY sourcecode /var/www/html/
COPY httpd.conf /etc/httpd/conf/httpd.conf
COPY www.conf /etc/php-fpm.d/www.conf
RUN groupadd www-data && useradd -g www-data www-data -s /bin/bash
RUN chown -hR www-data:www-data /run/httpd/ && chown -hR www-data:www-data /var/www/ && chown -hR www-data:www-data /etc/httpd/ && chown -hR www-data:www-data /var/log/httpd/ && chown -hR www-data:www-data /etc/php* && chown -hR www-data:www-data /run/php-fpm && chown -hR www-data:www-data /var/log/php-fpm

#setcap to bind to privileged ports as non-root
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/httpd &&  getcap /usr/sbin/httpd

USER 1000
CMD /usr/sbin/php-fpm -D ; /usr/sbin/httpd -D FOREGROUND
EXPOSE 8080

What might be the issue, iam unable to get the issue..!
Is there anyother way to run container with non-root?

Source: Docker Questions

LEAVE A COMMENT