Skip to content
Prev Previous commit
Next Next commit
the -u option is not necessary on a rootless environment (rewrite by …
…hroncok)
  • Loading branch information
themr0c committed Jun 3, 2020
commit a8887d2cfe3c5a1c1fb29b5029162e575bc49093
25 changes: 9 additions & 16 deletions pre_commit/languages/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,15 @@ def install_environment(


def get_docker_user() -> Tuple[str, ...]: # pragma: win32 no cover
try:
rootless = False
output = subprocess.check_output(('docker', 'system', 'info'), text=True)
for line in output.splitlines():
# rootless docker has "rootless"
# rootless podman has "rootless: true"
if line.strip().startswith('rootless'):
if not 'false' in line:
rootless = True
break
if not rootless:
return ('-u', f'{os.getuid()}:{os.getgid()}')
else:
return()
except AttributeError:
return ()
output = subprocess.check_output(('docker', 'system', 'info'), text=True)
for line in output.splitlines():
# rootless docker has "rootless"
# rootless podman has "rootless: true"
if line.strip().startswith('rootless'):
if not 'false' in line:
return () # no -u for rootless
break
Comment thread
themr0c marked this conversation as resolved.
return ('-u', f'{os.getuid()}:{os.getgid()}')


def docker_cmd() -> Tuple[str, ...]: # pragma: win32 no cover
Expand Down