如何使用docker-compose.yml获取root访问权限

时间:2017-10-30 05:26:09

标签: docker nginx docker-compose

我使用下面的配置yml:

web:
image: nginx:latest
ports:
    - "8080:80"
volumes:
    - ./code:/code
    - ./site.conf:/etc/nginx/conf.d/site.conf

访问/etc/nginx/var/log/nginx/error.log的权限错误。

$ docker-compose up
Creating crmapicoremain_web_1 ... 
Creating crmapicoremain_web_1 ... done
Attaching to crmapicoremain_web_1
web_1  | nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
web_1  | 2017/10/30 05:45:48 [emerg] 1#1: no port in upstream "php-fpm" in /etc/nginx/conf.d/CRM.conf:18
crmapicoremain_web_1 exited with code 1

如何使用docker-compose.yml访问root用户?

1 个答案:

答案 0 :(得分:2)

请尝试将SELinux设置为Permissive/Disabled,然后重试。

su -c "setenforce 0"

请注意这会降低您的安全性而不建议在生产环境中使用。您应该尝试解决问题并启用SELinux。