Package cloud.localstack.docker
Class Container
java.lang.Object
cloud.localstack.docker.Container
public class Container
extends java.lang.Object
An 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
Modifier and Type Method Description static ContainercreateLocalstackContainer(java.lang.String externalHostName, boolean pullNewImage, boolean randomizePorts, java.lang.String imageTag, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.Integer,java.lang.Integer> portMappings)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)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 Details
-
LOCALSTACK_EXTERNAL_HOSTNAME
public static final java.lang.String LOCALSTACK_EXTERNAL_HOSTNAME- See Also:
- Constant Field Values
-
-
Method Details
-
createLocalstackContainer
public static Container createLocalstackContainer(java.lang.String externalHostName, boolean pullNewImage, boolean randomizePorts, java.lang.String imageTag, java.util.Map<java.lang.String,java.lang.String> environmentVariables, java.util.Map<java.lang.Integer,java.lang.Integer> portMappings)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 machineenvironmentVariables- map of environment variables to be passed to the docker container
-
getRunningLocalstackContainer
-
getRunningLocalstackContainer
-
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) -
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
-