Class DockerRemoteTerminal

  • All Implemented Interfaces:
    com.oracle.bedrock.Option, Deployer, RemoteTerminal

    public class DockerRemoteTerminal
    extends Object
    implements RemoteTerminal, Deployer
    A specialized RemoteTerminal used to generate Docker images and launch Docker containers from those images.

    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

      • DockerRemoteTerminal

        public DockerRemoteTerminal​(com.oracle.bedrock.runtime.Platform platform)
        Construct a new DockerRemoteTerminal.
        Parameters:
        platform - the Platform the commands will run on
    • Method Detail

      • makeDirectories

        public void makeDirectories​(String directoryName,
                                    com.oracle.bedrock.OptionsByType optionsByType)
        Write any mkdir commands to the Dockerfile
        Specified by:
        makeDirectories in interface RemoteTerminal
        Parameters:
        directoryName - the directory to create
        optionsByType - the OptionsByType controlling the build of the Dockerfile
      • writeDockerFile

        protected File writeDockerFile​(RemoteTerminal.Launchable launchable,
                                       String baseImage,
                                       com.oracle.bedrock.OptionsByType optionsByType)
                                throws IOException
        Write a Dockerfile that can be used to run the application.
        Parameters:
        launchable - the RemoteTerminal.Launchable to use
        baseImage - the name of the base image to use in the Dockerfile FROM statement
        optionsByType - the OptionsByType to use
        Returns:
        the File representing the Dockerfile created
        Throws:
        IOException - if there is an error writing the Dockerfile
      • createImage

        protected DockerImage createImage​(String imageTag,
                                          File dockerFile,
                                          Docker docker,
                                          com.oracle.bedrock.OptionsByType optionsByType)
        Create a Docker image.

        The image will contain all of the required artifacts to run the application. The image will be tagged with a random UUID.

        Parameters:
        imageTag - the tag to apply to the image
        dockerFile - the Dockerfile to use to build the image
        docker - the Docker environment to use
        optionsByType - the OptionsByType to use
        Returns:
        a DockerImage representing the built image
      • runContainer

        protected com.oracle.bedrock.runtime.ApplicationProcess runContainer​(String containerName,
                                                                             RemoteTerminal.Launchable launchable,
                                                                             DockerImage image,
                                                                             Docker docker,
                                                                             com.oracle.bedrock.OptionsByType optionsByType)
        Run a container using the specified image.
        Parameters:
        containerName - the name of the container
        launchable - the RemoteTerminal.Launchable that will give the command to execute
        image - the image to use to run the container
        docker - the Docker environment to use
        optionsByType - the OptionsByType to use
        Returns:
        a DockerContainer representing the running image