Class DockerUtils


  • public class DockerUtils
    extends java.lang.Object
    Utility class to get metadata for dockerized containers
    • Constructor Summary

      Constructors 
      Constructor Description
      DockerUtils()  
      DockerUtils​(java.net.URL cgroupLocation)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable java.lang.String getContainerId()
      Reads the docker-generated cgroup file that lists the full (untruncated) docker container ID at the end of each line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DockerUtils

        public DockerUtils()
      • DockerUtils

        public DockerUtils​(java.net.URL cgroupLocation)
    • Method Detail

      • getContainerId

        public @Nullable java.lang.String getContainerId()
                                                  throws java.io.IOException
        Reads the docker-generated cgroup file that lists the full (untruncated) docker container ID at the end of each line. This method takes advantage of that fact by just reading the 64-character ID from the end of the first line.
        Returns:
        the untruncated Docker container ID, or null if it can't be read
        Throws:
        java.io.IOException - if the file cannot be read