Class DockerContainerDescriptor

java.lang.Object
de.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor
de.iip_ecosphere.platform.ecsRuntime.docker.DockerContainerDescriptor
All Implemented Interfaces:
de.iip_ecosphere.platform.ecsRuntime.ContainerDescriptor

public class DockerContainerDescriptor extends de.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor
Implements a container descriptor for docker-based container management.
Author:
Monika Staciwa, SSE
  • Field Details

    • PORT_PLACEHOLDER

      public static final String PORT_PLACEHOLDER
      See Also:
    • PORT_PLACEHOLDER_1

      public static final String PORT_PLACEHOLDER_1
      See Also:
    • instanceCount

      private static int instanceCount
    • instance

      private int instance
    • dockerId

      private String dockerId
    • downloadedImageZipfile

      private String downloadedImageZipfile
    • dockerImageName

      private String dockerImageName
    • dood

      private boolean dood
    • attachStdIn

      private boolean attachStdIn
    • attachStdOut

      private boolean attachStdOut
    • attachStdErr

      private boolean attachStdErr
    • privileged

      private boolean privileged
    • withTty

      private boolean withTty
    • networkMode

      private String networkMode
    • exposedPorts

      private ArrayList<String> exposedPorts
    • env

      private ArrayList<String> env
  • Constructor Details

    • DockerContainerDescriptor

      public DockerContainerDescriptor()
      Creates a container descriptor instance.
    • DockerContainerDescriptor

      protected DockerContainerDescriptor(String id, String name, de.iip_ecosphere.platform.support.Version version, URI uri)
      Creates a container descriptor instance.
      Parameters:
      id - the container id
      name - the (file) name of the container
      version - the version of the container
      uri - the URI where the descriptor was loaded from
      Throws:
      IllegalArgumentException - if id, name, version or uri is invalid, e.g., null or empty
  • Method Details

    • setDockerId

      void setDockerId(String dockerId)
      Defines the Docker container's id.
      Parameters:
      dockerId -
    • getDockerId

      public String getDockerId()
      Returns the Docker container's id.
      Returns:
      Docker id
    • setDockerImageName

      public void setDockerImageName(String dockerImageName)
      Defines the name of the Docker image. [required by SnakeYaml]
      Parameters:
      dockerImageName -
    • getDockerImageName

      public String getDockerImageName()
      Returns the name of the Docker image.
      Returns:
      name
    • setDownloadedImageZipfile

      void setDownloadedImageZipfile(String name)
      Defines the name of the downloaded file with the Docker image.
      Parameters:
      name -
    • getDownloadedImageZipfile

      public String getDownloadedImageZipfile()
      Returns a name of downloaded file with the Docker image.
      Returns:
      image's name
    • setExposedPorts

      public void setExposedPorts(ArrayList<String> exposedPorts)
      Defines the exposed ports. [required by SnakeYaml]
      Parameters:
      exposedPorts - the exposed ports
    • getExposedPorts

      public ArrayList<String> getExposedPorts()
      Returns the ports exposed by the container.
      Returns:
      the exposed ports
    • instantiateExposedPorts

      public List<com.github.dockerjava.api.model.ExposedPort> instantiateExposedPorts(int port, int port1)
      Instantiates the exposed by the container.
      Parameters:
      port - to replace PORT_PLACEHOLDER
      port1 - to replace PORT_PLACEHOLDER_1
      Returns:
      the exposed ports
    • setEnv

      public void setEnv(ArrayList<String> env)
      Defines the environment settings to start the container. [required by SnakeYaml]
      Parameters:
      env - the environment settings, may contain PORT_PLACEHOLDER to be replaced by the dynamic port of the AAS implementation server of the service manager
    • getNetworkMode

      public String getNetworkMode()
      Returns the network mode.
      Returns:
      the network mode, may be null for none
    • getEnv

      public ArrayList<String> getEnv()
      Returns the plain environment settings to start the container.
      Returns:
      the environment settings, may contain PORT_PLACEHOLDER}
    • getDood

      public boolean getDood()
      Returns whether the container shall allow for managing containers (DooD).
      Returns:
      true if docker shall be available/mapped, false else
      See Also:
    • getWithTty

      public boolean getWithTty()
      Returns whether the container shall provide an interactive terminal.
      Returns:
      true if the terminal shall be provided, false else
      See Also:
    • getPrivileged

      public boolean getPrivileged()
      Returns whether the container shall run in privileged mode.
      Returns:
      true if privileged model shall apply, false else
    • getAttachStdErr

      public boolean getAttachStdErr()
      Returns whether standard error shall be attached to the container.
      Returns:
      true to attach, false else
    • getAttachStdIn

      public boolean getAttachStdIn()
      Returns whether standard in shall be attached to the container.
      Returns:
      true to attach, false else
      See Also:
    • getAttachStdOut

      public boolean getAttachStdOut()
      Returns whether standard out shall be attached to the container.
      Returns:
      true to attach, false else
    • setNetworkMode

      public void setNetworkMode(String networkMode)
      Defines the network mode. [snakeyaml]
      Parameters:
      networkMode - the network mode, may be null for none
    • setPrivileged

      public void setPrivileged(boolean privileged)
      Changes whether the container shall run in privileged mode. [snakeyaml]
      Parameters:
      privileged - true if privileged model shall apply, false else
    • setDood

      public void setDood(boolean dood)
      Changes whether the container shall allow for managing containers (DooD).
      Parameters:
      dood - true if docker shall be available/mapped, false else
    • setWithTty

      public void setWithTty(boolean withTty)
      Returns whether the container shall provide an interactive terminal.
      Parameters:
      withTty - true if the terminal shall be provided, false else
    • setAttachStdErr

      public void setAttachStdErr(boolean attachStdErr)
      Changes whether standard out shall be attached to the container.
      Parameters:
      attachStdErr - true to attach, false else
    • setAttachStdIn

      public void setAttachStdIn(boolean attachStdIn)
      Changes whether standard in shall be attached to the container.
      Parameters:
      attachStdIn - true to attach, false else
    • setAttachStdOut

      public void setAttachStdOut(boolean attachStdOut)
      Changes whether standard out shall be attached to the container.
      Parameters:
      attachStdOut - true to attach, false else
    • instantiateEnv

      public List<String> instantiateEnv(int port, int port1)
      Returns the substituted environment variable settings to start the container.
      Parameters:
      port - the port to substitute PORT_PLACEHOLDER
      port1 - the port to substitute PORT_PLACEHOLDER_1
      Returns:
      the instantiated environment variable settings
    • requiresPort

      public boolean requiresPort(String placeholder)
      Returns whether a dynamic port for a placeholder is required.
      Parameters:
      placeholder - the name of the placeholder
      Returns:
      true for dynamic port, false else
    • getNetKey

      public String getNetKey()
      Returns the key for the network manager.
      Returns:
      the key
    • getNetKey1

      public String getNetKey1()
      Returns the key for the network manager.
      Returns:
      the key
    • readFromYamlFile

      public static DockerContainerDescriptor readFromYamlFile(File file)
      Returns a DockerContainerDescriptor with a information from a yaml file.
      Parameters:
      file - yaml file
      Returns:
      DockerContainerDescriptor (may be null)
    • readFromYaml

      public static DockerContainerDescriptor readFromYaml(InputStream in, URI uri)
      Returns a DockerContainerDescriptor with a information from a yaml file.
      Parameters:
      in - an inout stream with Yaml contents (may be null)
      uri - the URI the descriptor was read from
      Returns:
      DockerContainerDescriptor (may be null)
    • getRepository

      public static String getRepository(String imgName)
      Turns a full container image name with optional registry, repository and version into its repository/name.
      Parameters:
      imgName - the image name
      Returns:
      the repository
    • getRegistry

      public static String getRegistry(String imgName)
      Turns a full container image name with optional registry, repository and version into its repository/name.
      Parameters:
      imgName - the image name
      Returns:
      the repository
    • getTag

      public static String getTag(String imgName)
      Turns a full container image name with optional registry, repository and version into its (version) tag.
      Parameters:
      imgName - the image name
      Returns:
      the tag, may be empty
    • main

      public static void main(String[] args)
      Tests reading a Docker container file.
      Parameters:
      args - arguments, first is taken as file name