Package com.atlassian.bamboo.docker
Class DockerContainerServiceImpl
java.lang.Object
com.atlassian.bamboo.docker.DockerContainerServiceImpl
- All Implemented Interfaces:
DockerContainerService
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable IntegergetHostPort(@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.booleanisRunning(@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.voidremove(@NotNull ProcessContext processContext, @NotNull Path dockerPath, @NotNull String containerName, @NotNull Path workingDirectory, @NotNull Map<String, String> environment) Removes the container with the given name.voidrun(@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:DockerContainerServiceStart a Docker container for the image provided.- Specified by:
runin interfaceDockerContainerService- Parameters:
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:DockerContainerServiceChecks if a container with the given name is running. If the container exists but has exited, this method will return false.- Specified by:
isRunningin interfaceDockerContainerService- Parameters:
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:DockerContainerServiceGets the host port mapped to the given container port.- Specified by:
getHostPortin interfaceDockerContainerService- Parameters:
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:DockerContainerServiceRemoves the container with the given name. This method will forcibly remove the container if it is running.- Specified by:
removein interfaceDockerContainerService- Parameters:
containerName- the name of the container to remove.- Throws:
DockerException
-