Class DockerContainerManager

java.lang.Object
de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>
de.iip_ecosphere.platform.ecsRuntime.docker.DockerContainerManager
All Implemented Interfaces:
de.iip_ecosphere.platform.ecsRuntime.ContainerManager, de.iip_ecosphere.platform.ecsRuntime.ContainerOperations

public class DockerContainerManager extends de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>
Implements a docker-based container manager for IIP-Ecosphere.
Author:
Monika Staciwa, SSE
  • Field Details

    • config

      private static DockerSetup config
    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
  • Constructor Details

    • DockerContainerManager

      public DockerContainerManager()
  • Method Details

    • getAuthConfig

      private static com.github.dockerjava.api.model.AuthConfig getAuthConfig(String authKey, String registry)
      Tries to obtain an authentication config from IdentityStore.
      Parameters:
      authKey - the authentication key, may be empty or null and is ignored then
      registry - the registry to authenticate for
      Returns:
      the authentication config or null for none
    • tryPull

      private String tryPull(DockerSetup setup, com.github.dockerjava.api.DockerClient dockerClient, DockerContainerDescriptor container) throws ExecutionException
      Tries to pull the container if a registry is given.
      Parameters:
      setup - the docker setup
      dockerClient - the docker client instance to use
      container - the actual container to load/add/pull
      Returns:
      the container id if it was pulled/is there
      Throws:
      ExecutionException - if pulling the container failed
    • addContainer

      public String addContainer(URI location) throws ExecutionException
      Throws:
      ExecutionException
    • getImageName

      private String getImageName(DockerContainerDescriptor desc)
      Validates and returns the docker image file name.
      Parameters:
      desc - the descriptor to return the name from
      Returns:
      the image file name, potentially turned to lower cases
    • configure

      private void configure(com.github.dockerjava.api.command.CreateContainerCmd cmd, int port, int port1, DockerContainerDescriptor container)
      Configures the create container command.
      Parameters:
      cmd - the command instance
      port - the port number for the AAS implementation server
      port1 - the second optional port number for the AAS implementation server
      container - the container descriptor
    • getDockerClient

      public com.github.dockerjava.api.DockerClient getDockerClient()
      Returns a Docker API Client. If there is not running Docker daemon on the host it returns null.
      Returns:
      DockerClient or null if no Docker daemon is running or if the docker dockerHost in the configuration setup cannot be applied, e.g., a Linux socket path on Windows
    • startContainer

      public void startContainer(String id) throws ExecutionException
      Throws:
      ExecutionException
    • stopContainer

      public void stopContainer(String id) throws ExecutionException
      Throws:
      ExecutionException
    • migrateContainer

      public void migrateContainer(String id, String resourceId) throws ExecutionException
      Specified by:
      migrateContainer in interface de.iip_ecosphere.platform.ecsRuntime.ContainerOperations
      Overrides:
      migrateContainer in class de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>
      Throws:
      ExecutionException
    • undeployContainer

      public void undeployContainer(String id) throws ExecutionException
      Specified by:
      undeployContainer in interface de.iip_ecosphere.platform.ecsRuntime.ContainerOperations
      Overrides:
      undeployContainer in class de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>
      Throws:
      ExecutionException
    • updateContainer

      public void updateContainer(String id, URI location) throws ExecutionException
      Throws:
      ExecutionException
    • getDockerId

      public String getDockerId(String name) throws ExecutionException
      Returns an id of a Docker container with a given name.
      Parameters:
      name - container's name
      Returns:
      docker container id/NULL
      Throws:
      ExecutionException - if connecting to Docker API Client failed
    • getContainerSystemName

      public String getContainerSystemName()
    • getRuntimeName

      public String getRuntimeName()
    • getContainerSystemVersion

      public String getContainerSystemVersion()