Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions in README cause root owned files to appear in the local filesystem #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ docker-compose exec web ./vendor/bin/grumphp run
To run the phpunit tests:

```bash
docker-compose exec web ./vendor/bin/phpunit
docker-compose exec --user=$(id -u):$(id -g) web ./vendor/bin/phpunit
Copy link
Contributor

@idimopoulos idimopoulos May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work 100% of the use cases.. What happens with docker is that the mapping of file ownership between the host and the container are based strictly on the User ID and the Group ID of the user that runs the command. That being said, it works in probably most of the cases as most unix systems tend to have the default user to be with GID and UID 1000.
This is what happens in your case as well (and mine too).
If however, you were a secondary user in your machine, with GID 1001 and UID 1001 this is a missdirection as the files would either again fail to create or have the files owned by root as well.
At least i mostly think it does :D

Copy link
Member Author

@pfrenssen pfrenssen May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "a secondary user"? Do you mean using su to switch to a different user?

Note that I am not hardcoding any UID and GID, but getting the correct values dynamically from the user running the command. It seems to work as expected.

I just tried this by creating a second user, and switching to it, and both id -u and id -g give the expected results:

[pieter@thinkarch ~]$ sudo useradd testuser
[pieter@thinkarch ~]$ sudo su testuser -s /bin/bash
[testuser@thinkarch pieter]$ id -u
2002
[testuser@thinkarch pieter]$ id -g
2002

I got this trick from here: docker/compose#1532

```

## Configuration
Expand Down