Docker permissions development environment using a host mounted volume Docker permissions development environment using a host mounted volume docker docker

Docker permissions development environment using a host mounted volume


One of the solutions is to execure the commands inside your container. I've tried multiple workarounds for the same issue I faced in the past. I find executing the command inside the container the most user-friendly.

Example command: docker-compose run CONTAINER_NAME php bin/console cache:clear. You may use make, ant or any modern tool to keep the commands short.

Example with Makefile:

all: | build run testbuild: | docker-compose-buildrun: | composer-install clear-cache############## docker composedocker-compose-build:        docker-compose build############## composercomposer-install:        docker-compose run app composer installcomposer-update:        docker-compose run app composer update############## cacheclear-cache:        docker-compose run app php bin/console cache:cleardocker-set-permissions:        docker-compose run app chown -R www-data:www-data var/logs        docker-compose run app chown -R www-data:www-data var/cache############## testtest:        docker-compose run app php bin/phpunit

Alternatively, you may introduce a .env file which contains a environment variables and then user one of the variables to run usermod command in the Docker container.