2

When trying to run my nginx docker-compose image with sudo docker-compose up I get the following error:

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)

My docker compose file looks like this:

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

The permission of the folder /var/log/nginx looks like this: drwxr-xr-x. 2 root root 41 Jul 4 22:04 nginx

I have sandboxed the file like this: sudo chcon -Rt svirt_sandbox_file_t /var/log/nginx.

Its probably SELinux blocking the access, but do not suggest to disable it as I intend to run with it turned on!

just_user
  • 11,769
  • 19
  • 90
  • 135

1 Answers1

0

Add :Z to all your volumes mounts: - /etc/letsencrypt/:/etc/letsencrypt/:Z and it should work (what is 'z' flag in docker container's volumes-from option?).

Olga
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](https://stackoverflow.com/review/late-answers/28220129) – Adam Marshall Feb 01 '21 at 19:41