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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplements the factory descriptor for hooking the Docker container manager into the ECS factory. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DockerSetupprivate static final de.iip_ecosphere.platform.support.logging.LoggerFields inherited from interface de.iip_ecosphere.platform.ecsRuntime.ContainerOperations
EXC_ALREADY_KNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddContainer(URI location) private voidconfigure(com.github.dockerjava.api.command.CreateContainerCmd cmd, int port, int port1, DockerContainerDescriptor container) Configures the create container command.private static com.github.dockerjava.api.model.AuthConfiggetAuthConfig(String authKey, String registry) Tries to obtain an authentication config fromIdentityStore.com.github.dockerjava.api.DockerClientReturns a Docker API Client.getDockerId(String name) Returns an id of a Docker container with a givenname.private StringValidates and returns the docker image file name.voidmigrateContainer(String id, String resourceId) voidstartContainer(String id) voidstopContainer(String id) private StringtryPull(DockerSetup setup, com.github.dockerjava.api.DockerClient dockerClient, DockerContainerDescriptor container) Tries to pull the container if a registry is given.voidvoidupdateContainer(String id, URI location) Methods inherited from class de.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager
addContainer, checkId, getContainer, getContainer, getContainers, getId, getIds, getState, resolveUri, setState, throwExecutionException, throwExecutionExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.ecsRuntime.ContainerManager
getVersion
-
Field Details
-
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 fromIdentityStore.- Parameters:
authKey- the authentication key, may be empty or null and is ignored thenregistry- 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 setupdockerClient- the docker client instance to usecontainer- 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
- Throws:
ExecutionException
-
getImageName
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 instanceport- the port number for the AAS implementation serverport1- the second optional port number for the AAS implementation servercontainer- 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
dockerHostin the configuration setup cannot be applied, e.g., a Linux socket path on Windows
-
startContainer
- Throws:
ExecutionException
-
stopContainer
- Throws:
ExecutionException
-
migrateContainer
- Specified by:
migrateContainerin interfacede.iip_ecosphere.platform.ecsRuntime.ContainerOperations- Overrides:
migrateContainerin classde.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>- Throws:
ExecutionException
-
undeployContainer
- Specified by:
undeployContainerin interfacede.iip_ecosphere.platform.ecsRuntime.ContainerOperations- Overrides:
undeployContainerin classde.iip_ecosphere.platform.ecsRuntime.AbstractContainerManager<DockerContainerDescriptor>- Throws:
ExecutionException
-
updateContainer
- Throws:
ExecutionException
-
getDockerId
Returns an id of a Docker container with a givenname.- Parameters:
name- container's name- Returns:
- docker container id/NULL
- Throws:
ExecutionException- if connecting to Docker API Client failed
-
getContainerSystemName
-
getRuntimeName
-
getContainerSystemVersion
-