Package dev.galasa.docker
Interface IDockerContainer
public interface IDockerContainer
Docker Container Resource Object
 
 Provides a resource object representing a Docker Container on a Docker
 Engine. The normal method of obtaining a Docker Container resource object is
 by using a field:-
 
The following are DSE Environment properties:-
 
 
 
 
@DockerContainer(dockerContainerTag="a", image="galasadocker/ivp:1.0.0")
 private IDockerContainer containerA;The following are DSE Environment properties:-
docker.container.TAG.name=BOB to define the name the container
 is to use.docker.container.TAG.leave.running=true to inform the DSE that
 the container is not to be killed at startup or stopped once the test is
 complete.docker.engine=http://localhost:2375 the Docker Server/Swarm the
 container is to run on.docker.registries=http://localhost:5000 a list of Docker
 registries to search for an image- 
Method Summary
Modifier and TypeMethodDescriptionIssue a command to a running container.Equivalent to exec(defaultResourceTimeout, commands...);Fetch the Resource Object representing the Docker Image of this container.longRetireves the exit code from the containerReturns a map of all the exposed ports of the container and the real host ports they have been mapped to.getFirstSocketForExposedPort(String exposedPort) A convenience method to obtain the first socket of an exposed port.getRandomSocketForExposedPort(String exposedPort) A convenience method to obtain a random socket for an exposed port that has been mapped to more than one host socket.booleanChecks with the docker engine to find the running state of this container.retrieveFile(String path) Retreievs a InputStream of a file on the container.retrieveFileAsString(String path) Retrieves a file from the container and passes the contents back as a string.Retrieve the full STDERR for the Docker ContainerRetrieve the full STDOUT for the Docker Containervoidstart()Start the Docker Container.voidStart the Docker Container with a provided galasa DockerContainerConfig.voidstop()Stop the Docker Container.voidstoreFile(String absolutePath, InputStream file) Stores a file onto the container. 
- 
Method Details
- 
getDockerImage
IDockerImage getDockerImage()Fetch the Resource Object representing the Docker Image of this container.- Returns:
 - a 
IDockerImagefor this container - never null 
 - 
getExposedPorts
Returns a map of all the exposed ports of the container and the real host ports they have been mapped to. An exposed port can be mapped to more than one host port. The exposed port in the format used by docker, eg if tcp port 80 is exposed by the image, then the port will be mapped to"tcp/80". TheInetSocketAddresswill contain the ip address of the host.- Returns:
 - a map of the exposed ports, never null
 - Throws:
 DockerManagerException
 - 
getFirstSocketForExposedPort
A convenience method to obtain the first socket of an exposed port. Normally an exposed port will only have one real socket, so this will usual way of obtaining the socket of an exposed port.- Parameters:
 exposedPort- - the name of the exposed port - eg"tcp/80"- Returns:
 InetSocketAddressof the first real port, or null if not exposed or not mapped
 - 
getRandomSocketForExposedPort
A convenience method to obtain a random socket for an exposed port that has been mapped to more than one host socket. Similar togetFirstSocketForExposedPort(String).- Parameters:
 exposedPort- - the name of the exposed port - eg"tcp/80"- Returns:
 InetSocketAddressof a random real port, or null if not exposed or not mapped
 - 
start
Start the Docker Container. The Docker Manager does not validate that the container is down, so if up it will throw an exception with the remote api failure, likely to be NOT MODIFIED.- Throws:
 DockerManagerException
 - 
startWithConfig
Start the Docker Container with a provided galasa DockerContainerConfig. This will stop and remove any previous containers.- Parameters:
 config-- Throws:
 DockerManagerException
 - 
stop
Stop the Docker Container. The Docker Manager does not validate that the container is up, so if down it will throw an exception with the remote api failure, likely to be NOT MODIFIED.- Throws:
 DockerManagerException
 - 
exec
Equivalent to exec(defaultResourceTimeout, commands...);- Parameters:
 command- - An array of command and its parameters- Returns:
 - Throws:
 DockerManagerException
 - 
exec
Issue a command to a running container. Will return aIDockerExecresource object. The command will continue to execute in the background.
Use:-
container.exec("ls","-l","/var/log");- Parameters:
 timeout- - A timeout in milliseconds for the command to send outputcommand- - An array of command and its parameters- Returns:
 IDockerExec- Throws:
 DockerManagerException
 - 
retrieveStdOut
Retrieve the full STDOUT for the Docker Container- Returns:
 - Full Container STDOUT contents
 - Throws:
 DockerManagerException
 - 
retrieveStdErr
Retrieve the full STDERR for the Docker Container- Returns:
 - Full Container STDERR contents
 - Throws:
 DockerManagerException
 - 
isRunning
Checks with the docker engine to find the running state of this container.- Returns:
 - boolean
 - Throws:
 DockerManagerException
 - 
getExitCode
Retireves the exit code from the container- Returns:
 - long
 - Throws:
 DockerManagerException
 - 
storeFile
Stores a file onto the container. Path must be fully qualified including the name of the file on the container.- Parameters:
 absolutePath-file-- Throws:
 DockerManagerException
 - 
retrieveFile
Retreievs a InputStream of a file on the container.- Parameters:
 path-- Returns:
 - Throws:
 DockerManagerException
 - 
retrieveFileAsString
Retrieves a file from the container and passes the contents back as a string.- Parameters:
 path-- Returns:
 - String
 - Throws:
 DockerManagerException
 
 -