Class ContainerUtils
java.lang.Object
org.aksw.commons.util.docker.ContainerUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends org.testcontainers.containers.GenericContainer<T>>
org.testcontainers.containers.GenericContainer<T> addCurrentUserAndGroup(org.testcontainers.containers.GenericContainer<T> container) static booleancanRunEntrypoint(String imageName, String entrypoint, String... commandPrefix) static booleancanRunEntrypoint(String imageName, String entrypoint, List<String> commandPrefix) static StringcheckImage(String imageName, String entryPoint, String whichCommand, String commandName) static StringcheckImageForCommand(String imageName, String commandName) Check whether a command exists in an image and return its path.static com.github.dockerjava.api.command.InspectContainerResponsedetectContainer(com.github.dockerjava.api.DockerClient dockerClient) booleanfileExistsInImage(String imageName, String pathInContainer) Check if a path exists in the filesystem of the given image, without starting a container.static com.github.dockerjava.api.command.InspectContainerResponsefindSelfByHostname(com.github.dockerjava.api.DockerClient docker) Find and inspect the container that matches this process's hostname.static intgetExitValue(org.testcontainers.containers.GenericContainer<?> container) static longgetExitValueLong(org.testcontainers.containers.GenericContainer<?> container) Get the exit value based on the container's info.static Stringstatic booleanstatic InputStreamnewInputStream(org.testcontainers.containers.GenericContainer<?> container) Starts a container and returns an input stream over its output.static intstatic intstatic voidsetGlobalRetryCountIfAbsent(int retryCount) static org.testcontainers.containers.BindModetoBindMode(com.github.dockerjava.api.model.AccessMode am) static voidwaitFor(org.testcontainers.containers.GenericContainer<?> container)
-
Constructor Details
-
ContainerUtils
public ContainerUtils()
-
-
Method Details
-
setGlobalRetryCountIfAbsent
public static void setGlobalRetryCountIfAbsent(int retryCount) -
toBindMode
public static org.testcontainers.containers.BindMode toBindMode(com.github.dockerjava.api.model.AccessMode am) -
getUserString
- Throws:
IOException
-
getExitValueLong
public static long getExitValueLong(org.testcontainers.containers.GenericContainer<?> container) Get the exit value based on the container's info. This will only work if the container has been stopped but not removed. -
getExitValue
public static int getExitValue(org.testcontainers.containers.GenericContainer<?> container) -
waitFor
public static void waitFor(org.testcontainers.containers.GenericContainer<?> container) throws InterruptedException - Throws:
InterruptedException
-
findSelfByHostname
public static com.github.dockerjava.api.command.InspectContainerResponse findSelfByHostname(com.github.dockerjava.api.DockerClient docker) Find and inspect the container that matches this process's hostname.- Returns:
- InspectContainerResponse of the matching container or null if none found.
- Throws:
IOException- if /etc/hostname can't be read
-
detectContainer
public static com.github.dockerjava.api.command.InspectContainerResponse detectContainer(com.github.dockerjava.api.DockerClient dockerClient) -
addCurrentUserAndGroup
public static <T extends org.testcontainers.containers.GenericContainer<T>> org.testcontainers.containers.GenericContainer<T> addCurrentUserAndGroup(org.testcontainers.containers.GenericContainer<T> container) throws IOException - Throws:
IOException
-
checkImageForCommand
-
checkImage
-
canRunEntrypoint
-
canRunEntrypoint
-
hasCommand
-
runCommand
-
runCommand
-
newInputStream
public static InputStream newInputStream(org.testcontainers.containers.GenericContainer<?> container) Starts a container and returns an input stream over its output. Closing the input stream terminates the container.- Parameters:
container- A container that has not yet been started.- Returns:
- An input stream over the container's output (STDOUT).
-
fileExistsInImage
-