gpt4 book ai didi

linux - 如何以非 root 用户身份运行 nginx 容器?

转载 作者:行者123 更新时间:2023-12-02 20:55:48 24 4
gpt4 key购买 nike

每次我尝试以非 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com