Created by matank on 12/22/2014.
| Type | Name and description |
|---|---|
CreateConfig |
createConfig |
DockerClient |
dockerClient |
java.lang.String |
id |
java.lang.String |
name |
StartConfig |
startConfig |
State |
state |
| Constructor and description |
|---|
DockerContainer
(DockerClient dockerClient, java.lang.String image, java.lang.String id = null) |
| Type | Name and description |
|---|---|
DockerContainer |
addCommand(java.lang.Object command)Add command to container. |
java.io.File |
copy(java.lang.String fileFromContainer, java.lang.String destinationFolder = null)Download file from the container. |
java.lang.Object |
copyTo(java.lang.String sourceFilePath, java.lang.String destinationFolder)Copy local file into the container. |
DockerContainer |
doCreate(boolean throwsExceptionOnConflict = true, boolean forceRecreateOnConflict = false)@param throwsExceptionOnConflict - If true, will throw exception on conflict during creation |
void |
doDelete(boolean force = false, boolean deleteVolume = false)Delete container. |
DockerContainer |
doPause()Pause all container processes. |
DockerContainer |
doRestart(int waitBeforeStopInSecs = 0) |
DockerContainer |
doStart()Start container and continue with the code immediately. |
DockerContainer |
doStart(java.lang.Object startConfig)Start container. |
DockerContainer |
doStart(int waitExecutionToEndInSec)Start container and wait until its execution finishes. |
DockerContainer |
doStart(boolean debugOutput) |
DockerContainer |
doStart(int waitExecutionToEndInSec, boolean debugOutput) |
DockerContainer |
doStart(int waitExecutionToEndInSec, java.lang.Object startConfig, boolean debugOutput = false)Start container. |
DockerContainer |
doStop(int waitBeforeStopInSecs = 0)Stop container. |
DockerContainer |
doUnPause()Pause all container processes. |
java.io.File |
downloadFile(java.lang.String fileToExtract, java.lang.String destinationFolder = null)Download file from the container. |
boolean |
equals(java.lang.Object o) |
DockerExec |
exec(java.lang.Object command, boolean attachStdout = true, boolean attachStdin = false, boolean attachStderr = false, boolean tty = false)Exec another process inside this container, available only if the container is in Running state. |
int |
exitCode()Get status code of a container. |
java.lang.Object |
get(java.lang.String relativePath, groovyx.net.http.ContentType contentType, java.util.Map<java.lang.String, java.lang.String> query = null) |
java.util.Map<java.lang.String, java.lang.String> |
getEnvs()Get Map of all environment variables inside a container. |
int |
getExternalPort(int internalPort, java.lang.String protocol = "tcp") |
State |
getState()Get State of a container, extracted from inspect. |
java.lang.Object |
inspect()Inspect the container config and status. |
boolean |
isExists()Check if container is exists in docker server. |
java.lang.String |
logs()Get logs of the container. |
java.lang.Object |
stats(boolean stream = false)Show stats of running container. |
java.lang.String |
toString() |
java.lang.Object |
top()Show processes running inside container. |
java.lang.Object |
uploadFile(java.lang.String fileToUpload, java.lang.String destinationFolder)Upload file to the container. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Add command to container.
NOTE: if EntryPoint is set with "exec $@" at the end to run another command,
then the commands should be written as bash script and supportMultiCommand should be set as FALSE.
(e.g. createConfig.addCommand("ifconfig ; hostname ; env", false))
command - Command to run inside container. Download file from the container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#copy-files-or-folders-from-a-container
fileToExtract - File to download, pass full path, or relative to last working directory.destinationFolder - Folder to extract to, default is "tmp". Copy local file into the container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#copy-files-or-folders-from-a-container
sourceFilePath - Path to a local file or a folder to push into the container archive.destinationFolder - Folder inside the container to copy
throwsExceptionOnConflict - - If true, will throw exception on conflict during creationforceRecreateOnConflict - - If true, will remove existing container roughly, and recreate container.
this flag required 'throwsExceptionOnConflict' to be false. Delete container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#remove-a-container
force - Deletes container even it is in running statedeleteVolume - Deletes all the data associated to this container Pause all container processes.
Start container and continue with the code immediately.
If you would like to wait until it finishes use doStart(int waitExecutionToEndInSec).
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#start-a-container
Start container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#start-a-container
startConfig - Pass specific startConfig without setting it in this object. Start container and wait until its execution finishes.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#start-a-container
waitExecutionToEndInSec - Seconds to wait until execution finishes, 0 don't wait at all. Start container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#start-a-container
waitExecutionToEndInSec - Seconds to wait until execution finishes, 0 don't wait at all.startConfig - Pass specific startConfig without setting it in this object. Stop container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#stop-a-container
waitBeforeStopInSecs - Seconds to wait before sending the stop signal. Pause all container processes.
Download file from the container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#copy-files-or-folders-from-a-container
fileToExtract - File to download, pass full path, or relative to last working directory.destinationFolder - Folder to extract to, default is "tmp". Exec another process inside this container, available only if the container is in Running state.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#exec-create
command - Command to execute inside the containerattachStdout - Collect the output of the commandattachStderr - Collect the error output of the command Get status code of a container.
Get Map of all environment variables inside a container.
Get State of a container, extracted from inspect.
Inspect the container config and status.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#inspect-a-container
Check if container is exists in docker server.
Get logs of the container.
Show stats of running container. (Available from Docker remote-api v1.19)
stream - Allows to stream the stats, default is false for a single request
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.18/#get-container-stats-based-on-resource-usageShow processes running inside container. https://docs.docker.com/reference/api/docker_remote_api_v1.18/#list-processes-running-inside-a-container
Upload file to the container.
https://docs.docker.com/reference/api/docker_remote_api_v1.18/#copy-files-or-folders-from-a-container
fileToUpload - Path to the file to upload, pass full path, or relative to last working directory.destinationFolder - Folder to upload toGroovy Documentation