When I create a file inside a container with docker-compose run web touch test
the file owns to root:root
. I want to change it to be $USER
without to use chown
.
I'm aware of the --user
option but it requires to have the user created on the Dockerfile
. I prefer to not change the Dockerfile
because it is committed on a git repo and I don't want to commit this because it is kind of personal config.
I tried to mount the file /etc/passwd
but the user is not present when we run a command. I can use su $USER -c "..."
but there is some issues with this.
So, what's the best way to set create new files with the owner set as the user of the host machine?