Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-64608

Detection "running inside container" fails with cgroup namespace "private" for docker daemon

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • docker-workflow-plugin
    • jenkins version 2.263.1
      docker-workflow version 1.25
      docker 20.10.2
      arch linux with kernel 5.4.86-1-lts (/proc/cmdline contains systemd.unified_cgroup_hierarchy=1 cgroup_no_v1=all)
      cgroups v2 enabled
      cgroups v1 disabled

      With cgroups v2 running on the host there is a change to the behavior of the docker daemon regarding cgroups:

      The default cgroup namespace mode (docker run --cgroupns) is "private" on v2, "host" on v1. (cf. https://github.com/docker/docker.github.io/blob/master/config/containers/runmetrics.md#running-docker-on-cgroup-v2).

      Without any changes to the docker configuration the coding in src/main/java/org/jenkinsci/plugins/docker/workflow/client/ControlGroup.java of the docker-workflow-plugin fails, since /proc/self/cgroup does no longer contain the host-cgroup for the container.

      A workaround is to set the option default-cgroupns-mode to "host" for the docker daemon.

      Another way of detecting the containerization is needed.

          [JENKINS-64608] Detection "running inside container" fails with cgroup namespace "private" for docker daemon

          Jörg created issue -
          Jörg made changes -
          Description Original: With cgroups v2 running on the host there is a change to the behavior of the docker daemon regarding cgroups:

          The default cgroup namespace mode ({{docker run --cgroupns}}) is "private" on v2, "host" on v1. (cf. [https://github.com/docker/docker.github.io/blob/master/config/containers/runmetrics.md#running-docker-on-cgroup-v2).]

          Without any changes to the docker configuration the coding in {color:#172b4d}[docker-workflow-plugin|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4]/[src|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src]/[main|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main]/[java|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java]/[org|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org]/[jenkinsci|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org/jenkinsci]/[plugins|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org/jenkinsci/plugins]/[docker|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org/jenkinsci/plugins/docker]/[workflow|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org/jenkinsci/plugins/docker/workflow]/[client/|https://github.com/jenkinsci/docker-workflow-plugin/tree/eb0b0db4791ca8b40fe38f53ec7668118a82b7b4/src/main/java/org/jenkinsci/plugins/docker/workflow/client]{color}{color:#172b4d}ControlGroup.jav{color}a fails, since /proc/self/cgroup does no longer contain the host-cgroup for the container.

          A workaround is to set the option default-cgroupns-mode to "host" for the docker daemon.

          Another way of detecting the containerization is needed.
          New: With cgroups v2 running on the host there is a change to the behavior of the docker daemon regarding cgroups:

          The default cgroup namespace mode ({{docker run --cgroupns}}) is "private" on v2, "host" on v1. (cf. [https://github.com/docker/docker.github.io/blob/master/config/containers/runmetrics.md#running-docker-on-cgroup-v2).]

          Without any changes to the docker configuration the coding in src/main/java/org/jenkinsci/plugins/docker/workflow/client/ControlGroup.java of the docker-workflow-plugin fails, since /proc/self/cgroup does no longer contain the host-cgroup for the container.

          A workaround is to set the option default-cgroupns-mode to "host" for the docker daemon.

          Another way of detecting the containerization is needed.
          Christian made changes -
          Link New: This issue is related to JENKINS-66568 [ JENKINS-66568 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-65602 [ JENKINS-65602 ]
          Jesse Glick made changes -
          Assignee New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Remote Link New: This issue links to "docker-workflow-plugin #280 (Web Link)" [ 28293 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Jesse Glick made changes -
          Released As New: https://github.com/jenkinsci/docker-workflow-plugin/releases/tag/528.v7c193a_0b_e67c
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]

            jglick Jesse Glick
            joergschray Jörg
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: