Package cloud.localstack.docker
Class Container
- java.lang.Object
-
- cloud.localstack.docker.Container
-
public class Container extends java.lang.ObjectAn abstraction of the LocalStack docker container. Provides port mappings, a way to poll the logs until a specified token appears, and the ability to stop the container.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOCALSTACK_EXTERNAL_HOSTNAME
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ContainercreateLocalstackContainer(java.lang.String externalHostName, boolean pullNewImage, boolean randomizePorts, java.lang.String imageName, java.lang.String imageTag, java.lang.String portEdge, java.lang.String portElasticSearch, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.Integer,java.lang.Integer> portMappings, java.util.Map<java.lang.String,java.lang.String> bindMounts, java.lang.String platform)It creates a container using the hostname given and the set of environment variables providedjava.lang.StringexecuteCommand(java.util.List<java.lang.String> command)Run a command on the container via docker execintgetExternalPortFor(int internalPort)Given an internal port, retrieve the publicly addressable port that maps to itstatic ContainergetRunningLocalstackContainer()static ContainergetRunningLocalstackContainer(java.lang.String containerId)booleanisRunning()voidstop()Stop the containervoidwaitForAllPorts(java.lang.String ip)voidwaitForLogToken(java.util.regex.Pattern pattern)Poll the docker logs until a specific token appears, then return.
-
-
-
Field Detail
-
LOCALSTACK_EXTERNAL_HOSTNAME
public static final java.lang.String LOCALSTACK_EXTERNAL_HOSTNAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
createLocalstackContainer
public static Container createLocalstackContainer(java.lang.String externalHostName, boolean pullNewImage, boolean randomizePorts, java.lang.String imageName, java.lang.String imageTag, java.lang.String portEdge, java.lang.String portElasticSearch, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.Integer,java.lang.Integer> portMappings, java.util.Map<java.lang.String,java.lang.String> bindMounts, java.lang.String platform)
It creates a container using the hostname given and the set of environment variables provided- Parameters:
externalHostName- hostname to be used by localstackpullNewImage- determines if docker pull should be run to update to the latest image of the containerrandomizePorts- determines if the container should expose the default local stack ports or if it should expose randomized ports in order to prevent conflicts with other localstack containers running on the same machineimageName- the name of the image defaults to "localstack/localstack" if nullimageTag- the tag of the image to pull, defaults to "latest" if nullenvironmentVariables- map of environment variables to be passed to the docker containerportMappings-bindMounts- Docker host to container volume mapping like /host/dir:/container/dir, be aware that the host directory must be an absolute pathplatform- target platform for the localstack docker image
-
getRunningLocalstackContainer
public static Container getRunningLocalstackContainer()
-
getRunningLocalstackContainer
public static Container getRunningLocalstackContainer(java.lang.String containerId)
-
getExternalPortFor
public int getExternalPortFor(int internalPort)
Given an internal port, retrieve the publicly addressable port that maps to it
-
waitForAllPorts
public void waitForAllPorts(java.lang.String ip)
-
isRunning
public boolean isRunning()
-
waitForLogToken
public void waitForLogToken(java.util.regex.Pattern pattern)
Poll the docker logs until a specific token appears, then return. Primarily used to look for the "Ready." token in the LocalStack logs.
-
stop
public void stop()
Stop the container
-
executeCommand
public java.lang.String executeCommand(java.util.List<java.lang.String> command)
Run a command on the container via docker exec
-
-