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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a container descriptor instance.protectedDockerContainerDescriptor(String id, String name, de.iip_ecosphere.platform.support.Version version, URI uri) Creates a container descriptor instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether standard error shall be attached to the container.booleanReturns whether standard in shall be attached to the container.booleanReturns whether standard out shall be attached to the container.Returns the Docker container's id.Returns the name of the Docker image.booleangetDood()Returns whether the container shall allow for managing containers (DooD).Returns a name of downloaded file with the Docker image.getEnv()Returns the plain environment settings to start the container.Returns the ports exposed by the container.Returns the key for the network manager.Returns the key for the network manager.Returns the network mode.booleanReturns whether the container shall run in privileged mode.static StringgetRegistry(String imgName) Turns a full container image name with optional registry, repository and version into its repository/name.static StringgetRepository(String imgName) Turns a full container image name with optional registry, repository and version into its repository/name.static StringTurns a full container image name with optional registry, repository and version into its (version) tag.booleanReturns whether the container shall provide an interactive terminal.instantiateEnv(int port, int port1) Returns the substituted environment variable settings to start the container.List<com.github.dockerjava.api.model.ExposedPort> instantiateExposedPorts(int port, int port1) Instantiates the exposed by the container.static voidTests reading a Docker container file.static DockerContainerDescriptorreadFromYaml(InputStream in, URI uri) Returns a DockerContainerDescriptor with a information from a yaml file.static DockerContainerDescriptorreadFromYamlFile(File file) Returns a DockerContainerDescriptor with a information from a yaml file.booleanrequiresPort(String placeholder) Returns whether a dynamic port for a placeholder is required.voidsetAttachStdErr(boolean attachStdErr) Changes whether standard out shall be attached to the container.voidsetAttachStdIn(boolean attachStdIn) Changes whether standard in shall be attached to the container.voidsetAttachStdOut(boolean attachStdOut) Changes whether standard out shall be attached to the container.(package private) voidsetDockerId(String dockerId) Defines the Docker container's id.voidsetDockerImageName(String dockerImageName) Defines the name of the Docker image.voidsetDood(boolean dood) Changes whether the container shall allow for managing containers (DooD).(package private) voidDefines the name of the downloaded file with the Docker image.voidDefines the environment settings to start the container.voidsetExposedPorts(ArrayList<String> exposedPorts) Defines the exposed ports.voidsetNetworkMode(String networkMode) Defines the network mode.voidsetPrivileged(boolean privileged) Changes whether the container shall run in privileged mode.voidsetWithTty(boolean withTty) Returns whether the container shall provide an interactive terminal.Methods inherited from class de.iip_ecosphere.platform.ecsRuntime.BasicContainerDescriptor
getDockerImageZipfile, getId, getImageFile, getName, getState, getUri, getVersion, setDockerImageZipfile, setId, setImageFile, setName, setState, setUri, setVersion
-
Field Details
-
PORT_PLACEHOLDER
- See Also:
-
PORT_PLACEHOLDER_1
- See Also:
-
instanceCount
private static int instanceCount -
instance
private int instance -
dockerId
-
downloadedImageZipfile
-
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
-
exposedPorts
-
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 idname- the (file) name of the containerversion- the version of the containeruri- the URI where the descriptor was loaded from- Throws:
IllegalArgumentException- ifid,name,versionoruriis invalid, e.g., null or empty
-
-
Method Details
-
setDockerId
Defines the Docker container's id.- Parameters:
dockerId-
-
getDockerId
Returns the Docker container's id.- Returns:
- Docker id
-
setDockerImageName
Defines the name of the Docker image. [required by SnakeYaml]- Parameters:
dockerImageName-
-
getDockerImageName
Returns the name of the Docker image.- Returns:
- name
-
setDownloadedImageZipfile
Defines the name of the downloaded file with the Docker image.- Parameters:
name-
-
getDownloadedImageZipfile
Returns a name of downloaded file with the Docker image.- Returns:
- image's name
-
setExposedPorts
Defines the exposed ports. [required by SnakeYaml]- Parameters:
exposedPorts- the exposed ports
-
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 replacePORT_PLACEHOLDERport1- to replacePORT_PLACEHOLDER_1- Returns:
- the exposed ports
-
setEnv
Defines the environment settings to start the container. [required by SnakeYaml]- Parameters:
env- the environment settings, may containPORT_PLACEHOLDERto be replaced by the dynamic port of the AAS implementation server of the service manager
-
getNetworkMode
Returns the network mode.- Returns:
- the network mode, may be null for none
-
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:
trueif docker shall be available/mapped,falseelse- See Also:
-
getWithTty
public boolean getWithTty()Returns whether the container shall provide an interactive terminal.- Returns:
trueif the terminal shall be provided,falseelse- See Also:
-
getPrivileged
public boolean getPrivileged()Returns whether the container shall run in privileged mode.- Returns:
trueif privileged model shall apply,falseelse
-
getAttachStdErr
public boolean getAttachStdErr()Returns whether standard error shall be attached to the container.- Returns:
trueto attach,falseelse
-
getAttachStdIn
public boolean getAttachStdIn()Returns whether standard in shall be attached to the container.- Returns:
trueto attach,falseelse- See Also:
-
getAttachStdOut
public boolean getAttachStdOut()Returns whether standard out shall be attached to the container.- Returns:
trueto attach,falseelse
-
setNetworkMode
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-trueif privileged model shall apply,falseelse
-
setDood
public void setDood(boolean dood) Changes whether the container shall allow for managing containers (DooD).- Parameters:
dood-trueif docker shall be available/mapped,falseelse
-
setWithTty
public void setWithTty(boolean withTty) Returns whether the container shall provide an interactive terminal.- Parameters:
withTty-trueif the terminal shall be provided,falseelse
-
setAttachStdErr
public void setAttachStdErr(boolean attachStdErr) Changes whether standard out shall be attached to the container.- Parameters:
attachStdErr-trueto attach,falseelse
-
setAttachStdIn
public void setAttachStdIn(boolean attachStdIn) Changes whether standard in shall be attached to the container.- Parameters:
attachStdIn-trueto attach,falseelse
-
setAttachStdOut
public void setAttachStdOut(boolean attachStdOut) Changes whether standard out shall be attached to the container.- Parameters:
attachStdOut-trueto attach,falseelse
-
instantiateEnv
Returns the substituted environment variable settings to start the container.- Parameters:
port- the port to substitutePORT_PLACEHOLDERport1- the port to substitutePORT_PLACEHOLDER_1- Returns:
- the instantiated environment variable settings
-
requiresPort
Returns whether a dynamic port for a placeholder is required.- Parameters:
placeholder- the name of the placeholder- Returns:
truefor dynamic port,falseelse
-
getNetKey
Returns the key for the network manager.- Returns:
- the key
-
getNetKey1
Returns the key for the network manager.- Returns:
- the key
-
readFromYamlFile
Returns a DockerContainerDescriptor with a information from a yaml file.- Parameters:
file- yaml file- Returns:
- DockerContainerDescriptor (may be null)
-
readFromYaml
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
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
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
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
Tests reading a Docker container file.- Parameters:
args- arguments, first is taken as file name
-