Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions pre_commit/languages/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ def install_environment(
os.mkdir(directory)


def get_docker_user() -> str: # pragma: win32 no cover
def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
try:
return f'{os.getuid()}:{os.getgid()}'
return ('-u', f'{os.getuid()}:{os.getgid()}')
except AttributeError:
return '1000:1000'
return ()


def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
return (
'docker', 'run',
'--rm',
'-u', get_docker_user(),
Comment thread
asottile marked this conversation as resolved.
*get_docker_user(),
# https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
# The `Z` option tells Docker to label the content with a private
# unshared label. Only the current container can use a private volume.
Expand Down
2 changes: 1 addition & 1 deletion tests/languages/docker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def invalid_attribute():
getuid=invalid_attribute,
getgid=invalid_attribute,
):
assert docker.get_docker_user() == '1000:1000'
assert docker.get_docker_user() == ()