pre-commit/pre_commit/languages
Matthew Hughes 466f6c4a39 Fix permission errors for mounts in rootless docker
By running containers in a rootless docker context as root. This is
because user and group IDs are remapped in the user namespaces uses by
rootless docker, and it's unlikely that the current user ID will map to
the same ID under this remap (see docs[1] for some more details).
Specifically, it means ownership of mounted volumes will not be for the
current user and trying to write can result in permission errors.

This change borrows heavily from an existing PR[2].

The output format of `docker system info` I don't think is
documented/guaranteed anywhere, but it should corresponding to the
format of a `/info` API request to Docker[3]

The added test _hopes_ to avoid regressions in this behaviour, but since
tests aren't run in a rootless docker context on the PR checks (and I
couldn't find an easy way to make it the case) there's still a risk of
regressions sneaking in.

Link: https://docs.docker.com/engine/security/rootless/ [1]
Link: https://github.com/pre-commit/pre-commit/pull/1484/ [2]
Link: https://docs.docker.com/reference/api/engine/version/v1.48/#tag/System/operation/SystemAuth [3]
Co-authored-by: Kurt von Laven <Kurt-von-Laven@users.noreply.github.com>
Co-authored-by: Fabrice Flore-Thébault <ffloreth@redhat.com>
2025-05-23 17:01:10 -04:00
..
__init__.py OMG we're running a hook 2014-03-13 22:12:33 -07:00
conda.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
coursier.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
dart.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
docker.py Fix permission errors for mounts in rootless docker 2025-05-23 17:01:10 -04:00
docker_image.py give docker a tty output when expecting color 2024-03-02 11:51:34 -05:00
dotnet.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
fail.py python3.9+ 2023-10-28 14:20:37 -04:00
golang.py disable automatic toolchain switching for golang hooks 2024-11-25 18:47:18 -05:00
haskell.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
julia.py Add support for julia hooks 2024-11-25 18:31:25 -05:00
lua.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
node.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
perl.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
pygrep.py python3.9+ 2023-10-28 14:20:37 -04:00
python.py adjust python default_language_version to prefer versioned exe 2025-03-18 14:55:24 -04:00
r.py fix: ensure env patch is applied for vanilla emulation 2025-01-20 13:13:36 -05:00
ruby.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
rust.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
script.py python3.9+ 2023-10-28 14:20:37 -04:00
swift.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
system.py move languages.all and languages.helpers out of languages 2023-02-20 18:03:45 -05:00