![](/img/trans.png)
[英]mysqlbackup: ERROR: Opening of file /var/lib/mysql/ibdata1 failed. Error code: 13, Permission denied
[英]nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
我目前在嘗試設置新用戶而不是在我的 docker 文件中使用 root 時遇到問題。 圖像構建良好,但是當我運行容器時出現以下錯誤:nginx: [emerg] mkdir() "/var/lib/nginx/tmp/client_body" failed (13: Permission denied)
下面是我的 dockerfile。 我正在使用 redhat UBi 圖像構建我的 dockerfile :
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"
COPY nginx.conf /etc/nginx/nginx.conf
#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 chmod 755 api-gatway:api-gatway /var/lib/nginx/
RUN chmod 755 api-gatway:api-gatway /var/log/nginx/
EXPOSE 80
USER api-gatway
CMD ["nginx", "-g", "daemon off;"]
任何想法為什么這仍然不起作用?
這張圖片有不同的問題:
chmod
使用不當chown
存在IMO 這個 Dockerfile 部分應該可以解決您的部分問題:
RUN mkdir -p /var/lib/nginx/tmp /var/log/nginx \
&& chown -R api-gatway:api-gatway /var/lib/nginx /var/log/nginx \
&& chmod -R 755 /var/lib/nginx /var/log/nginx
EXPOSE 1080
USER api-gatway
CMD ["nginx", "-g", "daemon off;"]
請記住還要更改 nginx 配置中的端口。
最后但並非最不重要的一點是,我認為您正在嘗試將 a 文件夾映射到/var/lib/nginx/tmp/client_body
因為我沒有看到圖像中復制了任何內容。 在這種情況下,您必須確保 docker 容器中的用戶可以讀取主機上的文件夾。
個人意見:最好使用官方的nginx
docker 鏡像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.