Fix GetCurrentContainerID() and corresponding test #345
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This PR adds a fall back container ID matching function to the hostname based container ID matching function introduced in #336, in order to fix the regression with containers using a custom hostname.
The
GetCurrentContainerID()function will try the hostname based container ID matching function on all files before using the fallback function in case it didn't get a valid container ID. Its signature has been altered to allow testing it with real files reads instead of testing only the matching functions. This slightly increased test coverage from 62.1 % to 64.2 %./proc/1/cpusethas been added as a third alternative to/proc/self/cgroupand/proc/self/mountinfo(it's one of the container ID source we use on nginx-proxy/acme-companion).matchDockerCurrentContainerID()has been renamed tomatchContainerIDWithHostname()for clarity. Claiming it matches the current container ID feels a bit untrue, as it just match a 64 characters hex starting with 12 characters HOSTNAME.