Class 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 Detail

      • DockerContainer

        public DockerContainer​(String name,
                               com.oracle.bedrock.OptionsByType optionsByType)
        Create a DockerContainer.
        Parameters:
        name - the name of the container
        optionsByType - the OptionsByType used 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 the Application used to run this container.
        Returns:
        the Application used to run this container
      • getOptions

        public com.oracle.bedrock.OptionsByType getOptions()
        Obtain the OptionsByType used to run this container.
        Returns:
        the OptionsByType used to run this container
      • getDockerEnvironment

        public Docker getDockerEnvironment()
        Obtain the Docker environment used to run this container.
        Returns:
        the Docker environment used to run this container
      • inspect

        public javax.json.JsonValue inspect​(String format)
        Obtain information about this DockerContainer as a JsonArray.

        The JsonArray will have a single entry that is the JSON representation of this DockerContainer's state.

        This equates to running the docker inspect command for this DockerContainer.

        Parameters:
        format - the format
        Returns:
        information about this DockerContainer as a JsonArray
        Throws:
        IllegalStateException - if this DockerContainer has not been added to an Application as a Feature.
      • 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 stop command for this container.

        Throws:
        IllegalStateException - if this DockerContainer has not been added to an Application as a Feature.
      • onAddingTo

        public void onAddingTo​(com.oracle.bedrock.extensible.Extensible extensible)
        Specified by:
        onAddingTo in interface com.oracle.bedrock.extensible.Feature
      • onRemovingFrom

        public void onRemovingFrom​(com.oracle.bedrock.extensible.Extensible extensible)
        Specified by:
        onRemovingFrom in interface com.oracle.bedrock.extensible.Feature
      • onLaunched

        public void onLaunched​(com.oracle.bedrock.runtime.Application application)
        Specified by:
        onLaunched in interface com.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:
        onClosing in interface com.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:
        onClosed in interface com.oracle.bedrock.runtime.ApplicationListener<com.oracle.bedrock.runtime.Application>