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.
Container.ExecResultCONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategySTATE_HEALTHY| Constructor and Description |
|---|
FixedHostPortGenericContainer(@NotNull java.lang.String dockerImageName)
Deprecated.
it is highly recommended that
FixedHostPortGenericContainer not be used, as it risks port conflicts. |
| 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, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindcopyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning@Deprecated
public FixedHostPortGenericContainer(@NotNull
@NotNull java.lang.String dockerImageName)
FixedHostPortGenericContainer not be used, as it risks port conflicts.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)