◐ Shell
reader mode source ↗
Skip to content

Fix docker-in-docker detection for cgroups v2#3535

Merged
asottile merged 1 commit into
pre-commit:mainfrom
br-rhrbacek:fix-cgroups
Nov 8, 2025
Merged

Fix docker-in-docker detection for cgroups v2#3535
asottile merged 1 commit into
pre-commit:mainfrom
br-rhrbacek:fix-cgroups

Conversation

@br-rhrbacek

Copy link
Copy Markdown
Contributor

Inspired by a similar issue in Jenkins, I propose to fix the broken container detection by using /proc/1/mountinfo.

@JasonAlt

JasonAlt commented Sep 5, 2025

Copy link
Copy Markdown

This seems to work for me. I believe the change to the contents of /proc/1/cgroup must be tied to the host version (or docker version?) not the guest version, so unfortunately I am in no position to verify if this change is backwards compatible.

bidorffOL added a commit to bidorffOL/cap that referenced this pull request Oct 13, 2025
It seems that using /proc/1/cgroup is now broken to detect docker. Other projects have been using /proc/1/mountinfo instead (see pre-commit/pre-commit#3535)
@asottile asottile changed the title Fix pre-commit unable to determine if it is in a container for Docker-in-Docker setups (pre-commit#3360) Nov 8, 2025
@asottile asottile enabled auto-merge November 8, 2025 20:39
Hide details View details @asottile asottile merged commit cb63a5c into pre-commit:main Nov 8, 2025
28 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 14, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [pre-commit](https://github.com/pre-commit/pre-commit) | minor | `4.3.0` -> `4.4.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>pre-commit/pre-commit (pre-commit)</summary>

### [`v4.4.0`](https://github.com/pre-commit/pre-commit/blob/HEAD/CHANGELOG.md#440---2025-11-08)

[Compare Source](pre-commit/pre-commit@v4.3.0...v4.4.0)

\==================

##### Features

- Add `--fail-fast` option to `pre-commit run`.
  - [#&#8203;3528](pre-commit/pre-commit#3528) MR by [@&#8203;JulianMaurin](https://github.com/JulianMaurin).
- Upgrade `ruby-build` / `rbenv`.
  - [#&#8203;3566](pre-commit/pre-commit#3566) MR by [@&#8203;asottile](https://github.com/asottile).
  - [#&#8203;3565](pre-commit/pre-commit#3565) issue by [@&#8203;MRigal](https://github.com/MRigal).
- Add `language: unsupported` / `language: unsupported_script` as aliases
  for `language: system` / `language: script` (which will eventually be
  deprecated).
  - [#&#8203;3577](pre-commit/pre-commit#3577) MR by [@&#8203;asottile](https://github.com/asottile).
- Add support docker-in-docker detection for cgroups v2.
  - [#&#8203;3535](pre-commit/pre-commit#3535) MR by [@&#8203;br-rhrbacek](https://github.com/br-rhrbacek).
  - [#&#8203;3360](pre-commit/pre-commit#3360) issue by [@&#8203;JasonAlt](https://github.com/JasonAlt).

##### Fixes

- Handle when docker gives `SecurityOptions: null`.
  - [#&#8203;3537](pre-commit/pre-commit#3537) MR by [@&#8203;asottile](https://github.com/asottile).
  - [#&#8203;3514](pre-commit/pre-commit#3514) issue by [@&#8203;jenstroeger](https://github.com/jenstroeger).
- Fix error context for invalid `stages` in `.pre-commit-config.yaml`.
  - [#&#8203;3576](pre-commit/pre-commit#3576) MR by [@&#8203;asottile](https://github.com/asottile).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNzMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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.

3 participants