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.AbstractWaitStrategyContainer.ExecResultCONTAINER_RUNNING_TIMEOUT_SEC, containerId, containerName, dockerClient, dockerDaemonInfo, INTERNAL_HOST_HOSTNAME, waitStrategySTATE_HEALTHY| Constructor and Description |
|---|
FixedHostPortGenericContainer(@NotNull java.lang.String dockerImageName) |
| Modifier and Type | Method and Description |
|---|---|
SELF |
withFixedExposedPort(int hostPort,
int containerPort)
Bind a fixed TCP port on the docker host to a container port
|
SELF |
withFixedExposedPort(int hostPort,
int containerPort,
InternetProtocol protocol)
Bind a fixed port on the docker host to a container port
|
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, configure, containerIsCreated, containerIsStarted, containerIsStarting, copyFileFromContainer, copyFileFromContainer, copyFileToContainer, copyFileToContainer, createVolumeDirectory, doStart, execInContainer, execInContainer, failed, fetchDockerDaemonInfo, finished, getDockerImageName, getEnv, getEnvMap, getIpAddress, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getTestHostIpAddress, getWaitStrategy, logger, setCommand, setCommand, setDockerImageName, setEnv, setWaitStrategy, start, starting, stop, succeeded, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withVolumesFrom, withWorkingDirectoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddFileSystemBind, followOutput, followOutput, getBinds, getCommandParts, getDockerClient, getDockerDaemonInfo, getExtraHosts, getImage, getLinkedContainers, getPortBindings, self, setBinds, setCommandParts, setExposedPorts, setExtraHosts, setImage, setLinkedContainers, setPortBindings, withEnv, withFileSystemBindgetContainerNamegetBoundPortNumbers, getContainerId, getContainerInfo, getContainerIpAddress, getCurrentContainerInfo, getExposedPorts, getFirstMappedPort, getMappedPort, isCreated, isHealthy, isRunningpublic FixedHostPortGenericContainer(@NotNull
@NotNull java.lang.String dockerImageName)
public SELF withFixedExposedPort(int hostPort, int containerPort)
hostPort - a port on the docker host, which must be availablecontainerPort - a port in the containerpublic SELF withFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol)
hostPort - a port on the docker host, which must be availablecontainerPort - a port in the containerprotocol - an internet protocol (tcp or udp)