Openshift Nginx permission problem [nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)] Openshift Nginx permission problem [nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)] nginx nginx

Openshift Nginx permission problem [nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)]


To resolve this. I think the Problem in this Dockerfile was that I used the COPY command to move my build and that did not exist. So here is my working

Dockerfile

FROM nginx:alpineLABEL maintainer="ReliefMelone"WORKDIR /appCOPY . .# Install node.jsRUN apk update && \    apk add nodejs npm python make curl g++# Build ApplicationRUN npm installRUN ./node_modules/@angular/cli/bin/ng build --configuration=${BUILD_CONFIG}RUN cp -r ./dist/. /usr/share/nginx/html# Configure NGINXCOPY ./openshift/nginx/nginx.conf /etc/nginx/nginx.confCOPY ./openshift/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confRUN chgrp -R root /var/cache/nginx /var/run /var/log/nginx && \    chmod -R 770 /var/cache/nginx /var/run /var/log/nginxEXPOSE 8080CMD ["nginx", "-g", "daemon off;"]

Note that under the Build Application section I now do

RUN cp -r ./dist/. /usr/share/nginx/html

instead of

COPY ./dist/my-app /usr/share/nginx/html

The copy will not work as I previously ran the ng build inside of the container the dist will only exist in the container as well, so I need to execute the copy command inside of that container


I was using openshift, with limited permissions, so I fixed this problem by using the following nginx image (rather than nginx:latest)

FROM nginxinc/nginx-unprivileged 


If you're here because you failed to deploy an example helm chart (e.g: helm create mychart), do just like @quasipolynomial suggested but instead change your deployment file pull the right image.

i.e

containters:     - image: nginxinc/nginx-unprivileged 

more info on the official unprivileged image: https://github.com/nginxinc/docker-nginx-unprivileged