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, dependencies, dockerClient, dockerDaemonInfo, INTERNAL_HOST_HOSTNAME, waitStrategy
STATE_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, containerIsStopped, containerIsStopping, copyFileFromContainer, copyFileFromContainer, copyFileToContainer, copyFileToContainer, createVolumeDirectory, dependsOn, dependsOn, doStart, equals, execInContainer, execInContainer, failed, fetchDockerDaemonInfo, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerDaemonInfo, 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, isPrivilegedMode, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind
getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning
public 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)