Package com.atlassian.bamboo.docker
Class DockerContainerServiceImpl
java.lang.Object
com.atlassian.bamboo.docker.DockerContainerServiceImpl
- All Implemented Interfaces:
DockerContainerService
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable Integer
getHostPort
(@NotNull ProcessContext processContext, @NotNull Path dockerPath, @NotNull String containerName, @NotNull Integer containerPort, @NotNull Path workingDirectory, @NotNull Map<String, String> environment) Gets the host port mapped to the given container port.boolean
isRunning
(@NotNull ProcessContext processContext, @NotNull Path dockerPath, @NotNull String containerName, @NotNull Path workingDirectory, @NotNull Map<String, String> environment) Checks if a container with the given name is running.void
remove
(@NotNull ProcessContext processContext, @NotNull Path dockerPath, @NotNull String containerName, @NotNull Path workingDirectory, @NotNull Map<String, String> environment) Removes the container with the given name.void
run
(@NotNull ProcessContext processContext, @NotNull Path dockerPath, @NotNull String imageName, @NotNull RunConfig runConfig, @NotNull Path workingDirectory, @NotNull Map<String, String> environment) Start a Docker container for the image provided.
-
Field Details
-
EQ_ARG
- See Also:
-
-
Constructor Details
-
DockerContainerServiceImpl
public DockerContainerServiceImpl()
-
-
Method Details
-
run
public void run(@NotNull @NotNull ProcessContext processContext, @NotNull @NotNull Path dockerPath, @NotNull @NotNull String imageName, @NotNull @NotNull RunConfig runConfig, @NotNull @NotNull Path workingDirectory, @NotNull @NotNull Map<String, String> environment) throws DockerExceptionDescription copied from interface:DockerContainerService
Start a Docker container for the image provided.- Specified by:
run
in interfaceDockerContainerService
imageName
- the image to run.runConfig
- The run configuration describing which parameters to include for the Docker run command.- Throws:
DockerException
-
isRunning
public boolean isRunning(@NotNull @NotNull ProcessContext processContext, @NotNull @NotNull Path dockerPath, @NotNull @NotNull String containerName, @NotNull @NotNull Path workingDirectory, @NotNull @NotNull Map<String, String> environment) throws DockerExceptionDescription copied from interface:DockerContainerService
Checks if a container with the given name is running. If the container exists but has exited, this method will return false.- Specified by:
isRunning
in interfaceDockerContainerService
containerName
- the name of the container to check.- Returns:
- true if the container is running, false otherwise.
- Throws:
DockerException
-
getHostPort
@Nullable public @Nullable Integer getHostPort(@NotNull @NotNull ProcessContext processContext, @NotNull @NotNull Path dockerPath, @NotNull @NotNull String containerName, @NotNull @NotNull Integer containerPort, @NotNull @NotNull Path workingDirectory, @NotNull @NotNull Map<String, String> environment) throws DockerExceptionDescription copied from interface:DockerContainerService
Gets the host port mapped to the given container port.- Specified by:
getHostPort
in interfaceDockerContainerService
containerName
- the name of the container to check.containerPort
- The container port.- Returns:
- The host port or null if there is no host port mapped to the container port.
- Throws:
DockerException
-
remove
public void remove(@NotNull @NotNull ProcessContext processContext, @NotNull @NotNull Path dockerPath, @NotNull @NotNull String containerName, @NotNull @NotNull Path workingDirectory, @NotNull @NotNull Map<String, String> environment) throws DockerExceptionDescription copied from interface:DockerContainerService
Removes the container with the given name. This method will forcibly remove the container if it is running.- Specified by:
remove
in interfaceDockerContainerService
containerName
- the name of the container to remove.- Throws:
DockerException
-