pre-commit/pre_commit
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
..
commands fix migrate-config for purelib yaml 2024-10-08 11:46:48 -04:00
languages Fix permission errors for mounts in rootless docker 2025-05-23 17:01:10 -04:00
meta_hooks python3.9+ 2023-10-28 14:20:37 -04:00
resources regenerate ruby-build archive 2024-09-28 13:07:55 -04:00
__init__.py Initial commit. 2014-03-12 20:25:19 -07:00
__main__.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
all_languages.py Add support for julia hooks 2024-11-25 18:31:25 -05:00
clientlib.py add warning for deprecates stages for remote repos on init 2024-09-30 20:41:50 -04:00
color.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
constants.py make --hook-type and stages match 2023-03-11 14:26:14 -05:00
envcontext.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
error_handler.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
errors.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
file_lock.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
git.py fix: crash on ambiguous ref 'HEAD' 2025-03-15 15:23:15 -04:00
hook.py python3.9+ 2023-10-28 14:20:37 -04:00
lang_base.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
logging_handler.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
main.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-01-12 16:32:44 +00:00
output.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
parse_shebang.py python3.9+ 2023-10-28 14:20:37 -04:00
prefix.py drop python 3.6 support 2022-01-18 18:44:20 -05:00
repository.py remove deprecated python_venv alias 2024-10-05 13:30:25 -04:00
staged_files_only.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
store.py add warning for deprecates stages for remote repos on init 2024-09-30 20:41:50 -04:00
util.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
xargs.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2024-07-29 21:59:19 +00:00
yaml.py change migrate-config to use yaml parse tree instead 2024-09-16 20:16:16 -04:00
yaml_rewrite.py change migrate-config to use yaml parse tree instead 2024-09-16 20:16:16 -04:00