Reputation: 371
There is problem with symfony cache and logs in docker containers. Web server executes from www-data user and group and when I do symfony cache clear from docker container using php that is installed on docker, it executes from root.
So if I remove var/logs/dev.log for example and open url in browser, new log.dev gets created with user and group: www-data:www-data, but after i do cache clear, it gets permissions root:root and url in browser gives error dev.log permission denied.
I am not sure whats the problem, but I guess somehow nginx operates under www-data and when I execute console commands they operate from root user.
I have 4 containers: nginx, php-fpm, mysql, rabbit.
I also use version 3 of docker compose, I thought of solution with group_add but its no longer available in version 3
How do I configure this?
=================
docker-compose is similar to this:
version: "3"
services:
nginx:
image: nginx:1.11
depends_on:
- php-fpm
links:
- php-fpm
environment:
- NGINX_PORT=80
- FASTCGI_HOST=php
- FASTCGI_PORT=9000
- DOCUMENT_ROOT=/usr/local/src/test-project/public
ports:
- 8095:80
volumes:
- .:/usr/local/src/test-project
- ./docker/nginx/templates/default.conf.template:/etc/nginx/conf.d/default.conf.template
- ./docker/nginx/entrypoint.sh:/entrypoint.sh
command: "/bin/bash /entrypoint.sh"
php-fpm:
build: docker/php
depends_on:
- db
extra_hosts:
- "test-project:127.0.0.1"
environment:
DATABASE_URL: pgsql://test-project_users:test-project_users@db:5432/test-project_users
APP_URL: 172.19.0.1:8095/
working_dir: /usr/local/src/test-project
volumes:
- .:/usr/local/src/test-project
db:
image: postgres
restart: always
ports:
- '5599:5432'
environment:
POSTGRES_DB: test-project_users
POSTGRES_USER: test-project_users
POSTGRES_PASSWORD: test-project_users
volumes:
- data:/var/lib/db
Upvotes: 1
Views: 836
Reputation: 469
The problem is, that you are clearing the cache as root user via command-line. you should run the clear statement with su www-data.
Upvotes: 0