nginxinc / docker-nginx

Official NGINX Dockerfiles
BSD 2-Clause "Simplified" License
3.27k stars 1.73k forks source link

Nginx user unable to run entrypoint #924

Closed RajeshwariSubramaniam closed 2 months ago

RajeshwariSubramaniam commented 2 months ago

Describe the bug

We are extending the nginx:alpine image and attempting to run Nginx as the nginx user instead of the root user. However, we encounter a permission error when executing the entrypoint.

It appears that the home directory for the nginx user is set to /var/cache/nginx, but the nginx user lacks sufficient permissions to create folders within this directory.

docker-nginx

To reproduce

Steps to reproduce the behavior:

  1. Create a Dockerfile with the following content:
    FROM nginx:1.27.1-alpine-slim
    USER nginx
  2. Build an image using the above Dockerfile.
  3. Run a container from the created image
  4. Observe the error.

Expected behavior

Since the home directory for the nginx user is /var/cache/nginx, the user should have the necessary permissions to create folders within this directory.

Your environment

Additional context

Add any other context about the problem here.

thresheek commented 2 months ago

That's normal, please see/use https://github.com/nginxinc/docker-nginx-unprivileged/ for that task.

RajeshwariSubramaniam commented 2 months ago

I wasn't aware. Thanks for sharing!