nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
I am currently running into a problem trying to set up a new user rather than using root in my docker file. The image builds fine, however when I run the container I get the following error: nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
Below is my dockerfile. I am using redhat UBi image build my dockerfile :
USER root
RUN microdnf --setopt=tsflags=nodocs install -y nginx procps shadow-utils net-tools ca-certificates dirmngr gnupg wget vim
&& microdnf clean all
&& rpm -q procps-ng
ENV NGINX_USER="api-gatway"
NGINXR_UID="8987"
NGINX_GROUP="api-gatway"
NGINX_GID="8987"
RUN set -ex;
groupadd -r --gid "$NGINX_GID" "$NGINX_GROUP";
useradd -r --uid "$NGINXR_UID" --gid "$NGINX_GID" "$NGINX_USER"
COPY nginx.conf /etc/nginx/nginx.conf
#To start up NGINX
EXPOSE 80
RUN mkdir -p /var/lib/nginx/
RUN mkdir -p /var/log/nginx/
RUN mkdir -p /var/lib/nginx/tmp/
# chown owner-user:owner-group directory
RUN chmod 755 api-gatway:api-gatway /var/lib/nginx/
RUN chmod 755 api-gatway:api-gatway /var/log/nginx/
EXPOSE 80
USER api-gatway
CMD ["nginx", "-g", "daemon off;"]
Any ideas why this is still not working?
Source: Docker Questions