每次我尝试以非 root 用户身份运行容器时,都会出现以下错误:
the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
Dockerfile:FROM nginx:1.17.6
RUN chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d
RUN chmod -R 777 /etc/nginx/conf.d
USER nginx
COPY app/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
CMD ["nginx","-g","daemon off;"]
最佳答案
使用来自 nginx 的无根 docker-imager。
图片
nginxinc/nginx-unprivileged
DockerHub https://hub.docker.com/r/nginxinc/nginx-unprivileged
GitHub
https://github.com/nginxinc/docker-nginx-unprivileged
关于linux - 如何以非 root 用户身份运行 nginx 容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63108119/