Class DockerClientConfigHandler

java.lang.Object
org.apache.hadoop.yarn.util.DockerClientConfigHandler

public final class DockerClientConfigHandler extends Object
Commonly needed actions for handling the Docker client configurations. Credentials that are used to access private Docker registries are supplied. Actions include:
  • Read the Docker client configuration json file from a FileSystem.
  • Extract the authentication information from the configuration into Token and Credentials objects.
  • Tokens are commonly shipped via the ContainerLaunchContext as a ByteBuffer, extract the Credentials.
  • Write the Docker client configuration json back to the local filesystem to be used by the Docker command line.
  • Method Details

    • readCredentialsFromConfigFile

      public static org.apache.hadoop.security.Credentials readCredentialsFromConfigFile(org.apache.hadoop.fs.Path configFile, org.apache.hadoop.conf.Configuration conf, String applicationId) throws IOException
      Read the Docker client configuration and extract the auth tokens into Credentials.
      Parameters:
      configFile - the Path to the Docker client configuration.
      conf - the Configuration object, needed by the FileSystem.
      applicationId - the application ID to associate the Credentials with.
      Returns:
      the populated Credential object with the Docker Tokens.
      Throws:
      IOException - if the file can not be read.
    • getCredentialsFromTokensByteBuffer

      public static org.apache.hadoop.security.Credentials getCredentialsFromTokensByteBuffer(ByteBuffer tokens) throws IOException
      Convert the Token ByteBuffer to the appropriate Credentials object.
      Parameters:
      tokens - the Tokens from the ContainerLaunchContext.
      Returns:
      the Credentials object populated from the Tokens.
      Throws:
      IOException - io error occur.
    • writeDockerCredentialsToPath

      public static boolean writeDockerCredentialsToPath(File outConfigFile, org.apache.hadoop.security.Credentials credentials) throws IOException
      Extract the Docker related tokens from the Credentials and write the Docker client configuration to the supplied File.
      Parameters:
      outConfigFile - the File to write the Docker client configuration to.
      credentials - the populated Credentials object.
      Returns:
      true if a Docker credential is found in the supplied credentials.
      Throws:
      IOException - if the write fails.