What is the procedure – I download the
dunglas/symfony-docker
repository,
then run the following command:
SYMFONY_VERSION=6.2.* docker compose up --build
After entering the container, I run the composer install command.
At this point, the files outside the container have root ownership.
Is there a trick to perform container operations while being able to edit them
outside the container, for example, in PHPStorm?
When i add
services:
php:
user: 1000:1000
clone project to new location
2. Run `docker compose build --pull --no-cache` to build fresh images
3. Run `docker compose up` (the logs will be displayed in the current shell)
get errors:
In Kernel.php line 575:
Unable to create the "cache" directory (/srv/app/var/cache/dev)
from host in project dir i run
sudo chmod 777 var
then
docker compose up
and same situation
Unable to create the "cache" directory (/srv/app/var/cache/dev).
soultion from https://github.com/dunglas/symfony-docker/blob/main/docs/troubleshooting.md#editing-permissions-on-linux also not working: :
docker-compose run --rm php chown -R $(id -u):$(id -g) .
its ok but when i run composer-require – owner is not my, so i cannot edit my vendors
when i run composer update i get
In GitDownloader.php line 248:
Failed to execute git show-ref --head -d
fatal: detected dubious ownership in repository at '/srv/app/vendor/..
2
Answers
In that github repo there is a troubleshooting docs. You can use a command provided there:
https://github.com/dunglas/symfony-docker/blob/main/docs/troubleshooting.md#editing-permissions-on-linux
The docker container is ran as
root
, therefore, the files it creates also belong toroot
.You can fix this by manually setting
user: <uid>:<gid>
in yourdocker-compose.yml
.This works most of the time, but not always, it depends on the image you’re using.
Check out this StackOverflow answer for more information.