每次我尝试以非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;"]
3条答案
按热度按时间ddrv8njm1#
使用nginx的无根docker-imager。
图片
DockerHub
https://hub.docker.com/r/nginxinc/nginx-unprivileged
GitHub
https://github.com/nginxinc/docker-nginx-unprivileged
hmae6n7t2#
您可以删除(或注解)
nginx.conf
文件顶部的user
指令。当你以
root
运行nginx时,这个指令是相关的。它定义了拥有nginx子进程的pid的用户。当你不以
root
的身份运行nginx时,这个指令是无关紧要的,你的nginx子进程是以你当前的用户运行的。yacmzcpb3#
尝试添加此