简体   繁体   中英

Docker share file-permissions with ubuntu user

frequently I've been running into issues with docker. Whenever I execute composer from within the container, I am not able to edit the installed files before chowning the files from outside the container again. Is it possible to pass my user (I've seen this before, but does it fix the problem?) to my docker-compose, so that docker installs all the files pretending to be me? What is the best practice here, or how do you do it in your projects?

For example:

$ docker-compose up -d
$ docker-compose exec php bash (enter container)
$ composer install bla (everything works fine)
$ ctrl + d (exit the container)
$ composer require bla/bla (yields the below error message)

./composer.json is not writable.

Thanks in advance.

If what you are looking for is to run a docker container as a non-root user, you could do something like this:

docker container run --user 1000:1000

If you need to run the container with the current user, change it to --user $(id -u):$(id -g)

In this post it's pretty well explained.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM