Docker卷,更改文件权限/所有者 [英] Docker volume, change file permissions/owner
问题描述
我正在docker容器中的轨道上运行ruby.如果生成类似docker-compose run rails rails g controller posts index show
的文件,则文件所有者为root.之后,我必须始终运行chown -R . $USER
,这很烦人.
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?
推荐答案
您可以使用docker-compose run --user $USER
运行,但是该用户必须已经存在于容器中,因此您必须在Dockerfile中创建它.
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.
这篇关于Docker卷,更改文件权限/所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!