GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pre-commit unable to determine if it is in a container from /proc/1/cgroup for Docker-in-Docker setups · Issue #3360 · pre-commit/pre-commit

Pre-commit unable to determine if it is in a container from /proc/1/cgroup for Docker-in-Docker setups #3360

New issue
Copy link
New issue
Copy link
Closed
Closed
Pre-commit unable to determine if it is in a container from /proc/1/cgroup for Docker-in-Docker setups#3360
Copy link

Description

@JasonAlt
JasonAlt
opened on Dec 2, 2024
Issue body actions

search you tried in the issue tracker

is:issue docker is:open

describe your issue

Developing in a Fedora 40 container on a Fedora 41 host, using Docker-in-Docker such that pre-commit can make use of existing containers for lint tests. It appears that the contents of /proc/1/cgroup has changed:

$ cat /proc/1/cgroup
0::/

This is in contrast to pre-commit's checks for _is_in_docker() and _get_container_id:

def _is_in_docker() -> bool:
    try:
        with open('/proc/1/cgroup', 'rb') as f:
            return b'docker' in f.read()
    ...

def _get_container_id() -> str:
    ...
    with open('/proc/1/cgroup', 'rb') as f:
        for line in f.readlines():
            if line.split(b':')[1] == b'cpuset':
                return os.path.basename(line.split(b':')[2]).strip().decode()
    ...

It's not clear yet what has changed with /proc/1/cgroup nor what the fix should be.

Host:

$ rpm -qa |grep docker
docker-ce-cli-27.3.1-1.fc41.x86_64
docker-ce-27.3.1-1.fc41.x86_64
docker-ce-rootless-extras-27.3.1-1.fc41.x86_64
docker-compose-plugin-2.29.7-1.fc41.x86_64
docker-buildx-plugin-0.17.1-1.fc41.x86_64

Guest:

$ rpm -qa |grep docker
docker-compose-plugin-2.29.7-1.fc40.x86_64
docker-buildx-plugin-0.17.1-1.fc40.x86_64
docker-ce-cli-27.3.1-1.fc40.x86_64

pre-commit --version

pre-commit 3.8.0

.pre-commit-config.yaml

repos:
  - repo: local
    hooks:
      - id: shfmt
        name: shfmt
        # shfmt versions can be found here:
        #   https://hub.docker.com/r/mvdan/shfmt/tags
        entry: mvdan/shfmt:v3.8.0
        language: docker_image
        types: [shell]
        args: ["-w"]

~/.cache/pre-commit/pre-commit.log (if present)

No response

Reacted by Nicolas Bonnotte, Cyril Jouve and Radek Hrbacek

Activity

  1. br-rhrbacek commented on Sep 1, 2025

    @br-rhrbacek
    br-rhrbacek
    on Sep 1, 2025
    Contributor
    More actions

    Hi, we are experiencing the same issue with Debian 11 and newer (cgroups v2 have been used since then). I found that a similar issue in Jenkins was solved by using /proc/1/mountinfo (jenkinsci/docker-workflow-plugin#280). Can you look at it and update the detection mechanism in pre-commit, too?

  2. asottile commented on Sep 1, 2025

    @asottile
    asottile
    on Sep 1, 2025
    Member
    More actions

    Can you look at it and update the detection mechanism in pre-commit, too?

    can you?

    Reacted by Radek Hrbacek
  3. br-rhrbacek
    added a commit that references this issue on Sep 5, 2025

    Fix pre-commit unable to determine if it is in a container for Docker…

    f0a7e5c
  4. br-rhrbacek commented on Sep 5, 2025

    @br-rhrbacek
    br-rhrbacek
    on Sep 5, 2025
    Contributor
    More actions

    I hope I did it right: #3535

  5. br-rhrbacek commented on Sep 25, 2025

    @br-rhrbacek
    br-rhrbacek
    on Sep 25, 2025
    Contributor
    More actions

    @asottile I finished the work. Please review the changes and tell me what to do next. Thank you.

  6. asottile commented on Nov 8, 2025

    @asottile
    asottile
    on Nov 8, 2025
    Member
    More actions

    via #3535

  7. asottile
    closed this as completedon Nov 8, 2025
  8. tmeijn
    added a commit that references this issue on Nov 14, 2025

    build(deps): update pre-commit to v4.4.0

    9e95828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.