I am trying running nginx container as non-root of all 3 distributions alpine/unprivilage-alpine/debian(buster-slim) but for all I am getting the master process running as non root. But ENV substitution is not taking place which I have added inside the docker file and also container shell is reachable but pod logs are showing this blocker message:
[warn] 1#1: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
I don’t have the nginx.conf to be configured it is appearing inside container when entered into the shell.
Please find my docker file :-
COPY ./config/nginx.conf.template /etc/nginx/conf.d/nginx.conf.template
COPY ./config/env.template /var/www/html/assets/env.template
COPY ./dist /var/www/html
CMD /bin/sh -c "envsubst ‘Var_1 Var_2 Var_3 Var_4’ < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf
&& envsubst ‘Var_5 Var_6’ < /var/www/html/assets/env.template > /var/www/html/assets/env.json
&& nginx -g 'daemon off;'"
The non-root user is already having sufficient permission with all the files I have shown in COPY & VOLUME(chown and chmod).
What additional permissions I am missing in my docker snippet??
Source: Docker Questions