【问题标题】:Trying to run docker nginx image with docker-compose on fedora coreos, 13: permission denied尝试在 Fedora Coreos 上使用 docker-compose 运行 docker nginx 映像,13:权限被拒绝
【发布时间】:2020-10-25 08:00:26
【问题描述】:

当尝试使用 sudo docker-compose up 运行我的 nginx docker-compose 映像时,我收到以下错误:

production_nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
production_nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
production_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
production_nginx | 10-listen-on-ipv6-by-default.sh: /etc/nginx/conf.d/default.conf is not a file or does not exist, exiting
production_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
production_nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
production_nginx | nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
production_nginx | 2020/07/04 22:04:37 [emerg] 1#1: open() "/var/log/nginx/error.log" failed (13: Permission denied)

我的 docker compose 文件如下所示:

version: "3.7"
services:
  nginx:
    image: nginx:latest
    container_name: production_nginx
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /etc/letsencrypt/:/etc/letsencrypt/
      - /opt/nginx_cache/:/opt/nginx_cache/
      - /var/home/core/config/nginx/dhparam.pem:/etc/nginx/dhparam.pem
      - /var/home/core/config/nginx/conf.d/:/etc/nginx/conf.d/
      - /var/home/core/config/files/:/var/home/core/config/files/
      - /var/home/core/config/nginx/nginx.conf:/etc/nginx/nginx.conf
      - /var/log/nginx/:/var/log/nginx/
    networks:
      - proxynet
      - abnet
      - dsnet

文件夹/var/log/nginx的权限如下:drwxr-xr-x. 2 root root 41 Jul 4 22:04 nginx

我已经像这样对文件进行沙盒处理:sudo chcon -Rt svirt_sandbox_file_t /var/log/nginx

它可能是 SELinux 阻止了访问,但不建议禁用它,因为我打算在它打开的情况下运行!

【问题讨论】:

    标签: docker nginx docker-compose selinux fedora-coreos


    【解决方案1】:

    将 :Z 添加到所有卷挂载中:- /etc/letsencrypt/:/etc/letsencrypt/:Z 它应该可以工作 (what is 'z' flag in docker container's volumes-from option?)。

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    猜你喜欢
    • 2020-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-08
    • 2022-09-22
    • 2020-06-12
    • 2019-11-13
    相关资源
    最近更新 更多