just_user
just_user

Reputation: 12059

Trying to run docker nginx image with docker-compose on fedora coreos, 13: permission denied

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!

Upvotes: 2

Views: 1134

Answers (1)

Olga
Olga

Reputation: 1

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?).

Upvotes: 0

Related Questions