Skip to content

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented Aug 3, 2021

This PR fixes #355

On some systems both /proc/1/cpuset and /proc/self/cgroup are left empty, leaving only /proc/self/mountinfo to retrieve the ID of the container docker-gen is running inside of. This file differs slightly from the two others and the GetCurrentContainerID() and matchContainerID() functions had to be rewritten to

  1. process each file separately
  2. use a different regexp for /proc/self/mountinfo

in order to avoir retrieving a 64 characters ID that is not the container ID.

@buchdag buchdag merged commit da4354f into main Aug 3, 2021
@buchdag buchdag deleted the fix-355 branch August 3, 2021 15:33
@multicast
Copy link

Matching container ID on the /etc/hostname in the mountinfo file instead of the first (in my case, overlay fs) may help.

@buchdag
Copy link
Member Author

buchdag commented Aug 3, 2021

That's more or less what the PR does, if matchContainerID() identifies the starting pattern of a /proc/<pid>/mountinfo files, it preprends containers/ to the regular expression, so that the function will match one of the lines with the correct ID instead of the first one.

It should work on setups similar to yours but that's unfortunately still a brittle solution without any guaranteed stability.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$CurrentContainer is null

2 participants