Skip to content

Don't use --user when running docker on windows - #1371

Merged
asottile merged 1 commit into
pre-commit:masterfrom
killuazhu:windows-no-user
Mar 20, 2020
Merged

Don't use --user when running docker on windows#1371
asottile merged 1 commit into
pre-commit:masterfrom
killuazhu:windows-no-user

Conversation

@killuazhu

Copy link
Copy Markdown
Contributor

Previous PR #1094 hard code the docker user to 1000:1000 on Windows platform. This is a fragile assumption since not all docker image would have user 1000 configured inside of the container.

Instead, we don't use docker user on Windows to allow it to use the default user defined on the image.

@killuazhu
killuazhu marked this pull request as ready for review March 19, 2020 20:59
@asottile

Copy link
Copy Markdown
Member

can you show a failure mode? usually it doesn't matter if there's a user with that uid inside

also it's "docker" ;)

Comment thread pre_commit/languages/docker.py
Comment thread pre_commit/languages/docker.py Outdated
@killuazhu

Copy link
Copy Markdown
Contributor Author

Wow, you reviewed fast... Let me fix some pre-commit issue and also address your comments! @asottile

@killuazhu

Copy link
Copy Markdown
Contributor Author

can you show a failure mode? usually it doesn't matter if there's a user with that uid inside

We have a docker image in which we pre-define some git configuration. It's been persisted in /root/.gitconfig. When running with a different or non-existed user such as 1000, he won't be able to retrieve these pre-defined value.

@killuazhu

Copy link
Copy Markdown
Contributor Author

@asottile comments addressed, build has passed! Ready for another look. Thank you!

@asottile

Copy link
Copy Markdown
Member

We have a docker image in which we pre-define some git configuration. It's been persisted in /root/.gitconfig. When running with a different or non-existed user such as 1000, he won't be able to retrieve these pre-defined value.

I don't think that this fixes that then, since the current user will still be used on POSIX platforms

you could instead put your in-container configuration at /etc/gitconfig and then you don't need to worry about the user

@killuazhu

killuazhu commented Mar 20, 2020

Copy link
Copy Markdown
Contributor Author

you could instead put your in-container configuration at /etc/gitconfig and then you don't need to worry about the user

You are correct. I'm able to mess around with /etc/gitconfig to persist that config at system level instead of user level.

OTOH, I still think it would be useful to accept the change in this PR. We can avoid using an imaginary user (1000) when running docker on Windows. What do you think? @asottile

@asottile

Copy link
Copy Markdown
Member

I'm torn because the current code "works", this change just makes it different 🤔

@asottile asottile changed the title Do not use doker user on Win32 Don't use --user when running docker on windows Mar 20, 2020

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@asottile
asottile merged commit 528c7af into pre-commit:master Mar 20, 2020
@killuazhu
killuazhu deleted the windows-no-user branch March 20, 2020 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants