Bash 错误:";“用户”;指令只有在主进程以超级用户权限运行时才有意义
嗨,当我尝试在dockerfile中实现一个新用户而不是使用根用户时,我遇到了以下错误Bash 错误:";“用户”;指令只有在主进程以超级用户权限运行时才有意义,bash,docker,nginx,permissions,dockerfile,Bash,Docker,Nginx,Permissions,Dockerfile,嗨,当我尝试在dockerfile中实现一个新用户而不是使用根用户时,我遇到了以下错误 2020-10-16T09:28:04.554363522Z nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5 2020-10-16T09:28:04.564
2020-10-16T09:28:04.554363522Z nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2020-10-16T09:28:04.564383012Z nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
2020-10-16T09:28:06.882365055Z nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2020-10-16T09:28:06.891084727Z nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
2020-10-16T09:28:09.331807870Z nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2020-10-16T09:28:09.342560643Z nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
下面是我创建的以下dockerfile。我已经创建了一个新的api网关,但是,当我构建docker映像并运行容器时,会出现上述错误
对于我需要实现哪些更改才能让用户而不是根用户工作,有什么建议吗
USER root
RUN microdnf --setopt=tsflags=nodocs install -y nginx procps shadow-utils net-tools ca-certificates dirmngr gnupg wget vim\
&& microdnf clean all \
&& rpm -q procps-ng
ENV NGINX_USER="api-gatway" \
NGINXR_UID="8987" \
NGINX_GROUP="api-gatway" \
NGINX_GID="8987"
RUN set -ex; \
groupadd -r --gid "$NGINX_GID" "$NGINX_GROUP"; \
useradd -r --uid "$NGINXR_UID" --gid "$NGINX_GID" "$NGINX_USER"
#To start up NGINX
EXPOSE 80
RUN mkdir -p /var/lib/nginx/
RUN mkdir -p /var/log/nginx/
RUN mkdir -p /var/lib/nginx/tmp/
RUN chown api-gatway /var/lib/nginx/
RUN chownd api-gatway /var/log/nginx/
USER api-gatway
CMD ["nginx", "-g", "daemon off;"]
由于您在Dockerfile中指定了备用
用户
,因此nginx无法在启动时切换用户。您可以在Dockerfile或nginx配置中指定一个用户,但这两者都没有意义。嗯,我已经在Kubernates集群上运行了docker映像,用户错误似乎消失了。但是权限被拒绝的错误仍然存在nginx:[emerg]mkdir()“/var/lib/nginx/tmp/client_body”失败(13:权限被拒绝)您是否修复了此问题?