Class DockerContainer
- java.lang.Object
-
- com.oracle.bedrock.runtime.docker.DockerContainer
-
- All Implemented Interfaces:
com.oracle.bedrock.extensible.Feature,com.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>
public class DockerContainer extends Object implements com.oracle.bedrock.extensible.Feature, com.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>
A representation of a Docker container.Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.- Author:
- Jonathan Knight
-
-
Constructor Summary
Constructors Constructor Description DockerContainer(String name, com.oracle.bedrock.OptionsByType optionsByType)Create aDockerContainer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.oracle.bedrock.runtime.ApplicationgetApplication()Obtain theApplicationused to run this container.DockergetDockerEnvironment()Obtain theDockerenvironment used to run this container.StringgetName()Obtain the name of this container.com.oracle.bedrock.OptionsByTypegetOptions()Obtain theOptionsByTypeused to run this container.StringgetStatus()Determine the container statusjavax.json.JsonValueinspect()Obtain information about thisDockerContaineras aJsonArray.javax.json.JsonValueinspect(String format)Obtain information about thisDockerContaineras aJsonArray.booleanisRunning()Determine whether the container is running.voidonAddingTo(com.oracle.bedrock.extensible.Extensible extensible)voidonClosed(com.oracle.bedrock.runtime.Application application, com.oracle.bedrock.OptionsByType optionsByType)voidonClosing(com.oracle.bedrock.runtime.Application application, com.oracle.bedrock.OptionsByType optionsByType)voidonLaunched(com.oracle.bedrock.runtime.Application application)voidonRemovingFrom(com.oracle.bedrock.extensible.Extensible extensible)voidremove(boolean force)Remove thisDockerContainer.voidstop()Stop this container.
-
-
-
Constructor Detail
-
DockerContainer
public DockerContainer(String name, com.oracle.bedrock.OptionsByType optionsByType)
Create aDockerContainer.- Parameters:
name- the name of the containeroptionsByType- theOptionsByTypeused to run the container
-
-
Method Detail
-
getName
public String getName()
Obtain the name of this container.- Returns:
- the name of this container
-
getApplication
public com.oracle.bedrock.runtime.Application getApplication()
Obtain theApplicationused to run this container.- Returns:
- the
Applicationused to run this container
-
getOptions
public com.oracle.bedrock.OptionsByType getOptions()
Obtain theOptionsByTypeused to run this container.- Returns:
- the
OptionsByTypeused to run this container
-
getDockerEnvironment
public Docker getDockerEnvironment()
Obtain theDockerenvironment used to run this container.- Returns:
- the
Dockerenvironment used to run this container
-
inspect
public javax.json.JsonValue inspect()
Obtain information about thisDockerContaineras aJsonArray.The
JsonArraywill have a single entry that is the JSON representation of thisDockerContainer's state.This equates to running the
docker inspectcommand for thisDockerContainer.- Returns:
- information about this
DockerContaineras aJsonArray - Throws:
IllegalStateException- if thisDockerContainerhas not been added to anApplicationas aFeature.
-
inspect
public javax.json.JsonValue inspect(String format)
Obtain information about thisDockerContaineras aJsonArray.The
JsonArraywill have a single entry that is the JSON representation of thisDockerContainer's state.This equates to running the
docker inspectcommand for thisDockerContainer.- Parameters:
format- the format- Returns:
- information about this
DockerContaineras aJsonArray - Throws:
IllegalStateException- if thisDockerContainerhas not been added to anApplicationas aFeature.
-
isRunning
public boolean isRunning()
Determine whether the container is running.- Returns:
- true if on inspection the container JSON State.Running is true
-
getStatus
public String getStatus()
Determine the container status- Returns:
- the value of the JSON State.Status on inspecting the container
-
stop
public void stop()
Stop this container.This equates to running the
docker stopcommand for this container.- Throws:
IllegalStateException- if thisDockerContainerhas not been added to anApplicationas aFeature.
-
remove
public void remove(boolean force)
Remove thisDockerContainer.This equates to running the
docker rmcommand for thisDockerContainer.This command will fail to execute if the
DockerContaineris still running.- Parameters:
force- whether to add --force to the Docker rm command- Throws:
IllegalStateException- if thisDockerContainerhas not been added to anApplicationas aFeature.
-
onAddingTo
public void onAddingTo(com.oracle.bedrock.extensible.Extensible extensible)
- Specified by:
onAddingToin interfacecom.oracle.bedrock.extensible.Feature
-
onRemovingFrom
public void onRemovingFrom(com.oracle.bedrock.extensible.Extensible extensible)
- Specified by:
onRemovingFromin interfacecom.oracle.bedrock.extensible.Feature
-
onLaunched
public void onLaunched(com.oracle.bedrock.runtime.Application application)
- Specified by:
onLaunchedin interfacecom.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>
-
onClosing
public void onClosing(com.oracle.bedrock.runtime.Application application, com.oracle.bedrock.OptionsByType optionsByType)- Specified by:
onClosingin interfacecom.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>
-
onClosed
public void onClosed(com.oracle.bedrock.runtime.Application application, com.oracle.bedrock.OptionsByType optionsByType)- Specified by:
onClosedin interfacecom.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>
-
-