FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Optimize Docker image pull by artnc · Pull Request #3573 · pre-commit/pre-commit · GitHub

Optimize Docker image pull - #3573

Closed
artnc wants to merge 1 commit into
pre-commit:mainfrom
artnc:optimize-docker-image-pull
Closed

Optimize Docker image pull#3573
artnc wants to merge 1 commit into
pre-commit:mainfrom
artnc:optimize-docker-image-pull

Conversation

artnc commented Nov 8, 2025
edited
Loading

Copy link
Copy Markdown

Currently language: docker_image will have each partition try to pull the same Docker image individually, which is unnecessarily slow because the image really only needs to be downloaded once.

This PR modifies language: docker_image to precache the image before running the entry command.

I tested in this repo with this hook:

-   repo: local
    hooks:
    -   id: test
        name: Test
        entry: ubuntu:22.04 echo
        language: docker_image
        types: [text]

Before this PR it takes 15 seconds:

$ docker rmi ubuntu:22.04 &> /dev/null; pre-commit run test --all-files --verbose
Test.....................................................................Passed
- hook id: test
- duration: 14.97s

Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
f85691aa4b90: Pull complete
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
pre_commit/hook.py testing/resources/logfile_repo/bin/hook.sh testing/languages tests/languages/lua_test.py pre_commit/lan
guages/python.py pre_commit/languages/dart.py pre_commit/commands/sample_config.py pre_commit/commands/migrate_config.py t
esting/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml pre_commit/prefix.py pre_commit/resources/empty_te
mplate_setup.py tests/languages/conda_test.py tests/output_test.py tests/yaml_rewrite_test.py testing/resources/prints_cwd
_repo/.pre-commit-hooks.yaml pre_commit/resources/empty_template_main.go testing/resources/exclude_types_repo/bin/hook.sh
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
f85691aa4b90: Pull complete
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
tests/prefix_test.py pre_commit/languages/fail.py pre_commit/resources/empty_template_.npmignore tests/languages/__init__.
py tests/commands/init_templatedir_test.py LICENSE tests/parse_shebang_test.py tests/languages/r_test.py pre_commit/comman
ds/install_uninstall.py testing/resources/not_found_exe/.pre-commit-hooks.yaml pre_commit/yaml_rewrite.py tests/color_test
.py pre_commit/resources/__init__.py pre_commit/languages/haskell.py testing/resources/types_repo/bin/hook.sh testing/reso
urces/script_hooks_repo/bin/hook.sh tests/languages/swift_test.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
pre_commit/resources/empty_template_Makefile.PL tests/git_test.py pre_commit/languages/docker_image.py tests/conftest.py p
re_commit/languages/lua.py tests/repository_test.py tests/languages/coursier_test.py tests/commands/try_repo_test.py pre_c
ommit/store.py .github/ISSUE_TEMPLATE/01_feature.yaml pre_commit/languages/ruby.py tests/meta_hooks/check_hooks_apply_test
.py .github/workflows/languages.yaml pre_commit/main.py .gitignore testing/resources/python_hooks_repo/setup.py pre_commit
/util.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
f85691aa4b90: Pull complete
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
tests/meta_hooks/identity_test.py testing/resources/logfile_repo/.pre-commit-hooks.yaml testing/resources/system_hook_with
_spaces_repo/.pre-commit-hooks.yaml tests/logging_handler_test.py pre_commit/resources/empty_template_pre-commit-package-d
ev-1.rockspec .pre-commit-hooks.yaml pre_commit/languages/__init__.py pre_commit/languages/swift.py testing/resources/arg_
per_line_hooks_repo/bin/hook.sh pre_commit/resources/empty_template_environment.yml pre_commit/commands/try_repo.py pre_co
mmit/languages/script.py tests/store_test.py pre_commit/lang_base.py testing/get-coursier.sh setup.py testing/resources/mo
dified_file_returns_zero_repo/bin/hook.sh
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
pre_commit/languages/julia.py tests/languages/rust_test.py tests/envcontext_test.py testing/resources/python3_hooks_repo/s
etup.py tests/languages/julia_test.py pre_commit/languages/pygrep.py tests/languages/golang_test.py testing/resources/excl
ude_types_repo/.pre-commit-hooks.yaml pre_commit/constants.py pre_commit/commands/run.py tox.ini tests/languages/dotnet_te
st.py pre_commit/git.py pre_commit/envcontext.py tests/meta_hooks/__init__.py tests/commands/__init__.py pre_commit/comman
ds/autoupdate.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
testing/resources/types_or_repo/.pre-commit-hooks.yaml testing/__init__.py tests/languages/perl_test.py README.md testing/
resources/python3_hooks_repo/.pre-commit-hooks.yaml pre_commit/resources/empty_template_renv.lock tests/languages/node_tes
t.py .github/ISSUE_TEMPLATE/config.yml testing/zipapp/python pre_commit/logging_handler.py pre_commit/error_handler.py pre
_commit/resources/empty_template_activate.R tests/lang_base_test.py pre_commit/file_lock.py tests/commands/migrate_config_
test.py .github/actions/pre-test/action.yml tests/languages/python_test.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
pre_commit/meta_hooks/check_useless_excludes.py pre_commit/resources/empty_template_Cargo.toml pre_commit/parse_shebang.py
 tests/languages/system_test.py pre_commit/meta_hooks/check_hooks_apply.py tests/languages/dart_test.py pre_commit/command
s/init_templatedir.py pre_commit/commands/validate_config.py testing/auto_namedtuple.py tests/commands/hook_impl_test.py t
esting/resources/arbitrary_bytes_repo/hook.sh pre_commit/languages/coursier.py pre_commit/staged_files_only.py pre_commit/
resources/empty_template_package.json testing/resources/stdout_stderr_repo/tty-check-entry tests/commands/run_test.py test
ing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
tests/meta_hooks/check_useless_excludes_test.py testing/zipapp/make testing/resources/modified_file_returns_zero_repo/bin/
hook2.sh testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml pre_commit/__main__.py testing/resources/types_repo/.
pre-commit-hooks.yaml testing/resources/modified_file_returns_zero_repo/bin/hook3.sh tests/commands/gc_test.py tests/langu
ages/haskell_test.py pre_commit/resources/empty_template_go.mod testing/resources/failing_hook_repo/bin/hook.sh pre_commit
/commands/validate_manifest.py tests/languages/pygrep_test.py pre_commit/languages/conda.py testing/resources/types_or_rep
o/bin/hook.sh tests/xargs_test.py pre_commit/languages/golang.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
tests/commands/sample_config_test.py CHANGELOG.md pre_commit/resources/empty_template_LICENSE.renv tests/languages/ruby_te
st.py testing/util.py testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml setup.cfg pre_commit/languages/dotnet.
py .pre-commit-config.yaml tests/commands/install_uninstall_test.py tests/commands/autoupdate_test.py tests/staged_files_o
nly_test.py testing/zipapp/Dockerfile pre_commit/output.py tests/commands/validate_manifest_test.py tests/__init__.py pre_
commit/clientlib.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
pre_commit/yaml.py testing/fixtures.py pre_commit/commands/__init__.py pre_commit/languages/rust.py .github/ISSUE_TEMPLATE
/00_bug.yaml pre_commit/languages/docker.py testing/resources/script_hooks_repo/.pre-commit-hooks.yaml pre_commit/language
s/node.py testing/resources/stdout_stderr_repo/stdout-stderr-entry pre_commit/languages/r.py pre_commit/all_languages.py .
github/workflows/main.yml tests/clientlib_test.py pre_commit/repository.py pre_commit/__init__.py tests/languages/fail_tes
t.py CONTRIBUTING.md
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Downloaded newer image for ubuntu:22.04
pre_commit/xargs.py pre_commit/meta_hooks/__init__.py tests/languages/docker_test.py testing/resources/python_hooks_repo/f
oo.py testing/get-dart.sh pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec tests/main_test.py re
quirements-dev.txt pre_commit/color.py pre_commit/resources/hook-tmpl testing/language_helpers.py pre_commit/meta_hooks/id
entity.py pre_commit/commands/gc.py tests/util_test.py testing/resources/failing_hook_repo/.pre-commit-hooks.yaml pre_comm
it/commands/clean.py pre_commit/commands/hook_impl.py
Unable to find image 'ubuntu:22.04' locally
22.04: Pulling from library/ubuntu
Digest: sha256:09506232a8004baa32c47d68f1e5c307d648fdd59f5e7eaa42aaf87914100db3
Status: Image is up to date for ubuntu:22.04
tests/languages/script_test.py testing/make-archives tests/error_handler_test.py pre_commit/errors.py testing/zipapp/entry
 pre_commit/languages/system.py testing/resources/python_hooks_repo/.pre-commit-hooks.yaml tests/languages/docker_image_te
st.py pre_commit/resources/empty_template_pubspec.yaml pre_commit/resources/empty_template_main.rs pre_commit/languages/pe
rl.py tests/commands/validate_config_test.py testing/resources/python3_hooks_repo/py3_hook.py tests/commands/clean_test.py

After this PR it takes 4 seconds:

$ docker rmi ubuntu:22.04 &> /dev/null; pre-commit run test --all-files --verbo
se
Test.....................................................................Passed
- hook id: test
- duration: 4.3s

pre_commit/hook.py testing/resources/logfile_repo/bin/hook.sh testing/languages tests/languages/lua_test.py pre_commit/lan
guages/python.py pre_commit/languages/dart.py pre_commit/commands/sample_config.py pre_commit/commands/migrate_config.py t
esting/resources/modified_file_returns_zero_repo/.pre-commit-hooks.yaml pre_commit/prefix.py pre_commit/resources/empty_te
mplate_setup.py tests/languages/conda_test.py tests/output_test.py tests/yaml_rewrite_test.py testing/resources/prints_cwd
_repo/.pre-commit-hooks.yaml pre_commit/resources/empty_template_main.go testing/resources/exclude_types_repo/bin/hook.sh
tests/prefix_test.py pre_commit/languages/fail.py pre_commit/resources/empty_template_.npmignore tests/languages/__init__.
py tests/commands/init_templatedir_test.py LICENSE tests/parse_shebang_test.py tests/languages/r_test.py pre_commit/comman
ds/install_uninstall.py testing/resources/not_found_exe/.pre-commit-hooks.yaml pre_commit/yaml_rewrite.py tests/color_test
.py pre_commit/resources/__init__.py pre_commit/languages/haskell.py testing/resources/types_repo/bin/hook.sh testing/reso
urces/script_hooks_repo/bin/hook.sh tests/languages/swift_test.py
pre_commit/resources/empty_template_Makefile.PL tests/git_test.py pre_commit/languages/docker_image.py tests/conftest.py p
re_commit/languages/lua.py tests/repository_test.py tests/languages/coursier_test.py tests/commands/try_repo_test.py pre_c
ommit/store.py .github/ISSUE_TEMPLATE/01_feature.yaml pre_commit/languages/ruby.py tests/meta_hooks/check_hooks_apply_test
.py .github/workflows/languages.yaml pre_commit/main.py .gitignore testing/resources/python_hooks_repo/setup.py pre_commit
/util.py
tests/meta_hooks/identity_test.py testing/resources/logfile_repo/.pre-commit-hooks.yaml testing/resources/system_hook_with
_spaces_repo/.pre-commit-hooks.yaml tests/logging_handler_test.py pre_commit/resources/empty_template_pre-commit-package-d
ev-1.rockspec .pre-commit-hooks.yaml pre_commit/languages/__init__.py pre_commit/languages/swift.py testing/resources/arg_
per_line_hooks_repo/bin/hook.sh pre_commit/resources/empty_template_environment.yml pre_commit/commands/try_repo.py pre_co
mmit/languages/script.py tests/store_test.py pre_commit/lang_base.py testing/get-coursier.sh setup.py testing/resources/mo
dified_file_returns_zero_repo/bin/hook.sh
pre_commit/languages/julia.py tests/languages/rust_test.py tests/envcontext_test.py testing/resources/python3_hooks_repo/s
etup.py tests/languages/julia_test.py pre_commit/languages/pygrep.py tests/languages/golang_test.py testing/resources/excl
ude_types_repo/.pre-commit-hooks.yaml pre_commit/constants.py pre_commit/commands/run.py tox.ini tests/languages/dotnet_te
st.py pre_commit/git.py pre_commit/envcontext.py tests/meta_hooks/__init__.py tests/commands/__init__.py pre_commit/comman
ds/autoupdate.py
testing/resources/types_or_repo/.pre-commit-hooks.yaml testing/__init__.py tests/languages/perl_test.py README.md testing/
resources/python3_hooks_repo/.pre-commit-hooks.yaml pre_commit/resources/empty_template_renv.lock tests/languages/node_tes
t.py .github/ISSUE_TEMPLATE/config.yml testing/zipapp/python pre_commit/logging_handler.py pre_commit/error_handler.py pre
_commit/resources/empty_template_activate.R tests/lang_base_test.py pre_commit/file_lock.py tests/commands/migrate_config_
test.py .github/actions/pre-test/action.yml tests/languages/python_test.py
pre_commit/meta_hooks/check_useless_excludes.py pre_commit/resources/empty_template_Cargo.toml pre_commit/parse_shebang.py
 tests/languages/system_test.py pre_commit/meta_hooks/check_hooks_apply.py tests/languages/dart_test.py pre_commit/command
s/init_templatedir.py pre_commit/commands/validate_config.py testing/auto_namedtuple.py tests/commands/hook_impl_test.py t
esting/resources/arbitrary_bytes_repo/hook.sh pre_commit/languages/coursier.py pre_commit/staged_files_only.py pre_commit/
resources/empty_template_package.json testing/resources/stdout_stderr_repo/tty-check-entry tests/commands/run_test.py test
ing/resources/arg_per_line_hooks_repo/.pre-commit-hooks.yaml
tests/meta_hooks/check_useless_excludes_test.py testing/zipapp/make testing/resources/modified_file_returns_zero_repo/bin/
hook2.sh testing/resources/stdout_stderr_repo/.pre-commit-hooks.yaml pre_commit/__main__.py testing/resources/types_repo/.
pre-commit-hooks.yaml testing/resources/modified_file_returns_zero_repo/bin/hook3.sh tests/commands/gc_test.py tests/langu
ages/haskell_test.py pre_commit/resources/empty_template_go.mod testing/resources/failing_hook_repo/bin/hook.sh pre_commit
/commands/validate_manifest.py tests/languages/pygrep_test.py pre_commit/languages/conda.py testing/resources/types_or_rep
o/bin/hook.sh tests/xargs_test.py pre_commit/languages/golang.py
tests/commands/sample_config_test.py CHANGELOG.md pre_commit/resources/empty_template_LICENSE.renv tests/languages/ruby_te
st.py testing/util.py testing/resources/arbitrary_bytes_repo/.pre-commit-hooks.yaml setup.cfg pre_commit/languages/dotnet.
py .pre-commit-config.yaml tests/commands/install_uninstall_test.py tests/commands/autoupdate_test.py tests/staged_files_o
nly_test.py testing/zipapp/Dockerfile pre_commit/output.py tests/commands/validate_manifest_test.py tests/__init__.py pre_
commit/clientlib.py
pre_commit/yaml.py testing/fixtures.py pre_commit/commands/__init__.py pre_commit/languages/rust.py .github/ISSUE_TEMPLATE
/00_bug.yaml pre_commit/languages/docker.py testing/resources/script_hooks_repo/.pre-commit-hooks.yaml pre_commit/language
s/node.py testing/resources/stdout_stderr_repo/stdout-stderr-entry pre_commit/languages/r.py pre_commit/all_languages.py .
github/workflows/main.yml tests/clientlib_test.py pre_commit/repository.py pre_commit/__init__.py tests/languages/fail_tes
t.py CONTRIBUTING.md
pre_commit/xargs.py pre_commit/meta_hooks/__init__.py tests/languages/docker_test.py testing/resources/python_hooks_repo/f
oo.py testing/get-dart.sh pre_commit/resources/empty_template_pre_commit_placeholder_package.gemspec tests/main_test.py re
quirements-dev.txt pre_commit/color.py pre_commit/resources/hook-tmpl testing/language_helpers.py pre_commit/meta_hooks/id
entity.py pre_commit/commands/gc.py tests/util_test.py testing/resources/failing_hook_repo/.pre-commit-hooks.yaml pre_comm
it/commands/clean.py pre_commit/commands/hook_impl.py
tests/languages/script_test.py testing/make-archives tests/error_handler_test.py pre_commit/errors.py testing/zipapp/entry
 pre_commit/languages/system.py testing/resources/python_hooks_repo/.pre-commit-hooks.yaml tests/languages/docker_image_te
st.py pre_commit/resources/empty_template_pubspec.yaml pre_commit/resources/empty_template_main.rs pre_commit/languages/pe
rl.py tests/commands/validate_config_test.py testing/resources/python3_hooks_repo/py3_hook.py tests/commands/clean_test.py

Note the before run's twelve occurrences of "Pulling from library/ubuntu" and the after run's 3.5x speed improvement.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think this actually works. your output indicates you profiled against a pulled and a non-pulled image

the pull only happens once in the daemon so this doesn't actually do anything

# To prevent duplicate simultaneous image pull attempts in `run_xargs`, we
# try to precache the Docker image by pulling it here first
try:
image_name = cmd[2 if cmd[0] == '--entrypoint' else 0]

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this won't work reliably at all

Comment on lines +33 to +34
except Exception:
pass

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

? this is never acceptable

asottile closed this Nov 8, 2025

artnc commented Nov 8, 2025
edited
Loading

Copy link
Copy Markdown
Author

Thanks for your attention and fast response @asottile!

your output indicates you profiled against a pulled and a non-pulled image

My test commands were executing docker rmi ubuntu:22.04 before pre-commit to ensure that the image is non-pulled.

I believe that the "Pulling from library/ubuntu" message appears only in the before run's output because in the after run, the pull occurs outside of lang_base.run_xargs rather than inside of it.

the pull only happens once in the daemon so this doesn't actually do anything

The very reproducible timing differences suggest to me that the speed improvement is real and quite large. Here are several more alternating before/after runs with docker rmi in between:

$ git checkout main &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  1.29s user 1.31s system 25% cpu 10.000 total

$ git checkout optimize-docker-image-pull &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  0.79s user 0.52s system 27% cpu 4.704 total

$ git checkout main &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  1.25s user 1.31s system 18% cpu 13.661 total

$ git checkout optimize-docker-image-pull &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  0.79s user 0.51s system 28% cpu 4.565 total

$ git checkout main &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  1.22s user 1.27s system 16% cpu 15.536 total

$ git checkout optimize-docker-image-pull &> /dev/null
$ docker rmi ubuntu:22.04 &> /dev/null; time pre-commit run test --all-files --verbose &> /dev/null
pre-commit run test --all-files --verbose &> /dev/null  0.80s user 0.51s system 29% cpu 4.423 total

this won't work reliably at all
? this is never acceptable

Fair enough. In this PR, I'm just trying to greatly improve the most common cases while leaving the less common cases the same as before. I didn't want to let the perfect be the enemy of the good.

I'm happy to try modifying this PR to meet repo standards. In any case, this feels to me like a problem worth solving, whether in this PR or another one.

asottile commented Nov 8, 2025

Copy link
Copy Markdown
Member

I don't think what you're attempting is possible. any number of options could appear there.

artnc commented Nov 8, 2025
edited
Loading

Copy link
Copy Markdown
Author

Pre-commit's public docs state that entry is just a Docker image tag with possibly an entrypoint override (as opposed to a full-blown docker run arg list), but fair enough: maybe there are users who are relying on undocumented behavior.

I've updated this branch to add more test cases and simply skip the precaching attempt if any Docker flags other than --entrypoint are found. This optimizes all documented forms of entry while leaving the presumably much rarer undocumented usages untouched.

(More background on Duolingo's use case: we're running pre-commit on PRs as a required status check via GitHub Actions, which doesn't cache pulled Docker images, so every second counts.)

asottile commented Nov 8, 2025

Copy link
Copy Markdown
Member

then simply run docker pull in github actions

there's no way we can accurately simulate the same commandline parsing as docker

artnc commented Nov 8, 2025

Copy link
Copy Markdown
Author

then simply run docker pull in github actions

That's our current workaround, but it doesn't help the normal use case of devs running pre-commit locally.

there's no way we can accurately simulate the same commandline parsing as docker

pre-commit.com doesn't promise full parsing parity, just the entrypoint args I've handled here. If maintaining exactly the same pre-commit behavior in all cases is worth forgoing this PR's improvement of the documented cases, it could be worth updating the docs to advertise that entry is actually a docker run arg list so that users can confidently take advantage of that fact.

Anyway, you're now aware of the redundant download issue and I think I've offered all the help I can. Thanks again for your time here and for creating pre-commit - we've been using it heavily for nearly a decade.

asottile commented Nov 8, 2025

Copy link
Copy Markdown
Member

it doesn't help the normal use case of devs running pre-commit locally

only first run will incur that cost -- afterwards it's free

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL