Repository navigation
[JENKINS-72443] can not get container id if the Jenkins is running in a podman #713
Description
when try to use docker.image(), it will find the container id first. However, the current method getContainerIdIfContainerized() can not parse the container id because the return message of /proc/1/moutninfo is different. Please refer to the following.
cat /proc/1/mountinfo | grep /hostname
1339 1333 0:48 /containers/overlay-containers/4c4d5c5475f78f2b8a98e2894adcc3152ac587ac3c406a5c4eb74cc3f129c03c/userdata/hostname /etc/hostname rw,nosuid,nodev,relatime - tmpfs tmpfs rw,seclabel,size=1609596k,mode=700,uid=1001,gid=1001
Reproduction steps
- run a docker container in a podman container, on REHL8.
- go to the docker conainer
- run command: cat /proc/1/mountinfo | grep /hostname
- check the string which contains the contianer id.
Expected Results
the current code uses regexp "/containers/([a-z0-9]{64})/hostname" to parse the container id, so it expects /containers/[id]/hostname.
Actual Results
1339 1333 0:48 /containers/overlay-containers/4c4d5c5475f78f2b8a98e2894adcc3152ac587ac3c406a5c4eb74cc3f129c03c/userdata/hostname /etc/hostname rw,nosuid,nodev,relatime - tmpfs tmpfs rw,seclabel,size=1609596k,mode=700,uid=1001,gid=1001
Originally reported by
westmount, imported from: can not get container id if the Jenkins is running in a podman
- assignee:
naveenboni
- status: Open
- priority: Blocker
- component(s): docker-workflow-plugin
- resolution: Unresolved
- votes: 0
- watchers: 5
- imported: 2025-12-07
Raw content of original issue
when try to use docker.image(), it will find the container id first. However, the current method getContainerIdIfContainerized() can not parse the container id because the return message of /proc/1/moutninfo is different. Please refer to the following.
cat /proc/1/mountinfo | grep /hostname
1339 1333 0:48 /containers/overlay-containers/4c4d5c5475f78f2b8a98e2894adcc3152ac587ac3c406a5c4eb74cc3f129c03c/userdata/hostname /etc/hostname rw,nosuid,nodev,relatime - tmpfs tmpfs rw,seclabel,size=1609596k,mode=700,uid=1001,gid=1001
Reproduction steps
- run a docker container in a podman container, on REHL8.
- go to the docker conainer
- run command: cat /proc/1/mountinfo | grep /hostname
- check the string which contains the contianer id.
Expected Results
the current code uses regexp "/containers/([a-z0-9]{64})/hostname" to parse the container id, so it expects /containers/[id]/hostname.
Actual Results
1339 1333 0:48 /containers/overlay-containers/4c4d5c5475f78f2b8a98e2894adcc3152ac587ac3c406a5c4eb74cc3f129c03c/userdata/hostname /etc/hostname rw,nosuid,nodev,relatime - tmpfs tmpfs rw,seclabel,size=1609596k,mode=700,uid=1001,gid=1001
environment
REHL8,<br/>
Jenkins running in podman on REHL8, docker installed in Jenkins image
Activity
jenkins-infra-bot commentedon Dec 20, 2023
Raw content of original comment:
I think it will wok if we replace the regex hostnameMount "/containers/([a-z0-9] in file DockerClient.java.
jenkins-infra-bot commentedon Jan 9, 2024
Raw content of original comment:
Hi,
The above mentioned regular expression doesn't work (at least with sed).
This seems to work no matter if the host uses cgroup v1 or v2, and the container engine is docker or podman:
[root@783f0a980788 /]# cat /proc/self/mountinfo | sed -n '/ \/etc\/hostname /{s/.*\/\([a-f0-9]\{64,\}\)\/.*/\1/;p}' 783f0a980788c840ed872d982c574e30ce006494837c617acb2a168dae406bc2Which would be translated a bit different if the regex matching is done in pure java.
jenkins-infra-bot commentedon May 17, 2024
jeannette9728miller:
Raw content of original comment:
The issue lies in how Podman structures its container filesystems compared to Docker, which affects how Jenkins' Docker workflow plugin parses container IDs. Specifically, the regular expression used (/containers/([a-z0-9]
{64})/hostname) to identify the container ID from /proc/1/mountinfo does not match the Podman container filesystem path (/containers/overlay-containers/...).
Update the regular expression used in Jenkins' Docker workflow plugin to correctly parse the container ID from the Podman environment. You may need to adjust it to match the actual path structure used by Podman.
If the plugin's regular expression cannot be easily modified, consider writing a custom script or plugin extension specifically for Podman environments. This script would correctly parse the container ID from /proc/1/mountinfo based on Podman's filesystem layout.
Check for updates or patches to the Docker workflow plugin that may address compatibility with Podman. Sometimes, plugin updates include fixes or enhancements for different container runtimes.
As a temporary workaround, manually inspect /proc/1/mountinfo on your Podman host to understand its structure and identify the correct path or pattern to extract the container ID. This can help in adjusting the regular expression or writing a custom solution.