docker-nginx
docker-nginx copied to clipboard
Skip configuring image in read-only systems
The image in its current state fails when being run in read-only systems (https://github.com/nginxinc/docker-nginx-unprivileged/issues/43). This PR aims to fix that.
If the user is providing or relying on the scripts in /docker-entrypoint.d/ but not also providing the place they are expected to write as writeable, then the image shouldn't just ignore the scripts. Failure is the expected result so that they can fix their setup instead of getting a misconfigured service.
The intent (and the overall intent of the thread in the linked issue) of this PR is for the scripts to be ignored in read-only systems where the overall goal is for those scripts to be ignored altogether (aka systems that are set to read-only on purpose).
An alternative would be to provide an even more "minimal" version of the images that strips all the entrypoint scripts altogether, but I was trying to avoid adding yet another variant.
In that case, wouldn't the simplest solution be to just skip the entrypoint altogether since it isn't providing anything except running the default command?
This one fails since it can't create var/cache/nginx/client_temp or /var/run/nginx.pid, which this PR can't really address:
$ docker run -d --read-only --entrypoint nginx nginx:[version] -g 'daemon off'
The only difference between these is a little extra output at the beginning, but both run nginx:
$ docker run -it --rm --read-only --tmpfs /var/cache/nginx/ --tmpfs /var/run/ --entrypoint nginx nginx -g 'daemon off;'
$ docker run -it --rm --read-only --tmpfs /var/cache/nginx/ --tmpfs /var/run/ nginx