public class GenericContainer extends AbstractContainer implements LinkableContainer
Modifier and Type | Class and Description |
---|---|
static class |
GenericContainer.BindMode |
Modifier and Type | Field and Description |
---|---|
protected Map<String,List<com.spotify.docker.client.messages.PortBinding>> |
ports |
containerId, containerName, dockerClient, dockerHostIpAddress, tag
Constructor and Description |
---|
GenericContainer(String dockerImageName) |
Modifier and Type | Method and Description |
---|---|
void |
addEnv(String key,
String value)
Add an environment variable to be passed to the container.
|
void |
addFileSystemBind(String hostPath,
String containerPath,
GenericContainer.BindMode mode) |
protected void |
containerIsStarting(com.spotify.docker.client.messages.ContainerInfo containerInfo)
Hook to notify subclasses that the container is starting
|
protected void |
customizeHostConfigBuilder(com.spotify.docker.client.messages.HostConfig.Builder hostConfigBuilder)
Allows subclasses to apply additional configuration to the HostConfig.Builder prior to container creation.
|
protected com.spotify.docker.client.messages.ContainerConfig |
getContainerConfig() |
protected String |
getDockerImageName() |
String |
getIpAddress()
Get the IP address that this container may be reached on (may not be the local machine).
|
protected String |
getLivenessCheckPort() |
String |
getMappedPort(String originalPort)
Get the actual mapped port for a given port exposed by the container.
|
void |
setCommand(String command)
Set the command that should be run in the container
|
void |
setCommand(String[] commandParts)
Set the command that should be run in the container
|
void |
setExposedPorts(List<String> exposedPorts)
Set the ports that this container listens on
|
checkContainerNotAborted, createVolumeDirectory, getContainerName, logger, setTag, start, stop, waitForListeningPort, waitUntilContainerStarted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getContainerName
public GenericContainer(String dockerImageName)
protected void containerIsStarting(com.spotify.docker.client.messages.ContainerInfo containerInfo)
AbstractContainer
containerIsStarting
in class AbstractContainer
protected com.spotify.docker.client.messages.ContainerConfig getContainerConfig()
getContainerConfig
in class AbstractContainer
protected void customizeHostConfigBuilder(com.spotify.docker.client.messages.HostConfig.Builder hostConfigBuilder)
AbstractContainer
customizeHostConfigBuilder
in class AbstractContainer
protected String getLivenessCheckPort()
getLivenessCheckPort
in class AbstractContainer
protected String getDockerImageName()
getDockerImageName
in class AbstractContainer
public void setExposedPorts(List<String> exposedPorts)
exposedPorts
- a list of ports in 'number/protocol' format, e.g. '80/tcp'public void setCommand(String command)
command
- a command in single string format (will automatically be split on spaces)public void setCommand(String[] commandParts)
commandParts
- a command as an array of string partspublic String getIpAddress()
public String getMappedPort(String originalPort)
originalPort
- should be a String either containing just the port number or suffixed '/tcp', e.g. '80/tcp'public void addEnv(String key, String value)
key
- environment variable keyvalue
- environment variable valuepublic void addFileSystemBind(String hostPath, String containerPath, GenericContainer.BindMode mode)
Copyright © 2015. All rights reserved.