Docker volume, change file permissions/owner

2019-08-09 01:31发布

问题:

I'm running ruby on rails in a docker container. If I generate something like docker-compose run rails rails g controller posts index show, the file owner is root. After that I must always run chown -R . $USER and this is annoying.

Does any one know how I can fix this, so that the owner from each generated file is the host user?

回答1:

You can run with docker-compose run --user $USER, but that user must already exist in the container, so you'd have to create it in your Dockerfile.