public class FixedHostPortGenericContainer<SELF extends FixedHostPortGenericContainer<SELF>> extends GenericContainer<SELF>
GenericContainer
that allows a fixed port on the docker host to be mapped to a container port.
Normally this should not be required, and Docker should be allowed to choose a free host port instead. However, when a fixed host port is absolutely required for some reason, this class can be used to set it.
Callers are responsible for ensuring that this fixed port is actually available; failure will occur if it is not available - which could manifest as flaky or unstable tests.
GenericContainer.AbstractWaitStrategy
Container.ExecResult
CONTAINER_RUNNING_TIMEOUT_SEC, containerId, containerName, dockerClient, dockerDaemonInfo, waitStrategy
Constructor and Description |
---|
FixedHostPortGenericContainer(String dockerImageName) |
Modifier and Type | Method and Description |
---|---|
SELF |
withFixedExposedPort(int hostPort,
int containerPort)
Bind a fixed port on the docker host to a container port
|
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addLink, configure, containerIsStarted, containerIsStarting, createVolumeDirectory, execInContainer, execInContainer, fetchDockerDaemonInfo, finished, followOutput, followOutput, getContainerIpAddress, getDockerImageName, getIpAddress, getLivenessCheckPort, getMappedPort, getTestHostIpAddress, getWaitStrategy, isRunning, logger, setCommand, setCommand, setDockerImageName, start, starting, stop, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withCommand, withCommand, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withLogConsumer, withMinimumRunningDuration, withNetworkMode, withPrivilegedMode, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withWorkingDirectory
apply, failed, succeeded
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getDockerClient, getDockerDaemonInfo, getEnv, getExposedPorts, getExtraHosts, getImage, getLinkedContainers, getPortBindings, self, setBinds, setCommandParts, setContainerId, setContainerInfo, setContainerName, setDockerClient, setDockerDaemonInfo, setEnv, setExposedPorts, setExtraHosts, setImage, setLinkedContainers, setPortBindings, setWaitStrategy
public FixedHostPortGenericContainer(@NotNull String dockerImageName)
public SELF withFixedExposedPort(int hostPort, int containerPort)
hostPort
- a port on the docker host, which must be availablecontainerPort
- a port in the containerCopyright © 2017. All rights reserved.