symfony docker permission problems for cache files

后端 未结 2 1237
迷失自我
迷失自我 2021-02-15 11:58

I have a symfony setup for docker with docker-compose which is working well except when i run cache:clear from console, the webserver cant access the files.

I c

2条回答
  •  不知归路
    2021-02-15 12:21

    I'd think changing www-datas userid to your host-user's id is a good solution, as permissions for the host user are fairly easy to setup.

    #change www-data`s UID inside a Dockerfile
    RUN usermod -u [USERID] www-data 
    

    user id 1000 is the default for most linux systems afaik... 501 on mac
    you can run id -u on the host system to find out.

    You could then log into the container to run symfony commands as www-data

    docker exec -it -u www-data [CONTAINER] bash

    I was wondering how you could set the userid dynamically on container build. I guess passing it via --build-arg to docker-compose would be the way

    docker-compose build --build-arg USERID=$(id -u)
    

    ...but haven't managed to access that var in the Dockerfile yet.

提交回复
热议问题