symfony - Docker permissions development environment using a host mounted volume -
i'm using docker-compose set portable development environment bunch of symfony2 applications (though nothing want specific symfony). i've decided have source files on local machine exposed data volume other dependencies in docker. way developers can edit on local file-system.
everything works great, except after running app cache , log files , files created composer in /vendor directory owned root.
i've read problem , possible approaches here:
changing permissions of added file docker volume
but can't quite quite tease out changes have make in docker-compose.yml file when symphony container starts docker-compose up files created have permissions of user on host machine.
i'm posting file reference, worker php, etc. live:
source: image: symfony/worker-dev volumes: - $pwd:/var/www/app mongodb: image: mongo:2.4 ports: - "27017:27017" volumes_from: - source worker: image: symfony/worker-dev ports: - "80:80" - mongodb volumes_from: - source volumes: - "tmp/:/var/log/nginx"
one of solutions execure commands inside container. i've tried multiple workarounds same issue faced in past. find executing command inside container user-friendly.
example command: docker-compose run container_name php bin/console cache:clear
. may use make
, ant
or modern tool keep commands short.
example makefile
:
all: | build run test build: | docker-compose-build run: | composer-install clear-cache ############## docker compose docker-compose-build: docker-compose build ############## composer composer-install: docker-compose run app composer install composer-update: docker-compose run app composer update ############## cache clear-cache: docker-compose run app php bin/console cache:clear docker-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 ############## test test: docker-compose run app php bin/phpunit
alternatively, may introduce .env
file contains environment variables , user 1 of variables run usermod
command in docker container.
Comments
Post a Comment