Class DockerMachine


  • public class DockerMachine
    extends Object
    An encapsulation of a Docker Machine environment.

    Copyright (c) 2016. All Rights Reserved. Oracle Corporation.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

    Author:
    Jonathan Knight
    • Method Detail

      • getClientPlatform

        public com.oracle.bedrock.runtime.Platform getClientPlatform()
        Obtain the client Platform used to issue Docker Machine commands.
        Returns:
        Obtain the client Platform used to issue Docker Machine commands
      • withCommandOptions

        public DockerMachine withCommandOptions​(com.oracle.bedrock.runtime.options.Argument... args)
        Add the specified Docker Machine command option.
        Parameters:
        args - the command line option to add
        Returns:
        a new DockerMachine instance that is a copy of this DockerMachine with the specified command line option added
      • debug

        public DockerMachine debug()
        Enable debug mode.

        Equates to the --debug command option.

        Returns:
        a DockerMachine that is a copy of this instance with the --debug option applied
      • storagePath

        public DockerMachine storagePath​(File path)
        Specify the storage path.

        Equates to the --storage-path command option.

        Parameters:
        path - the storage path
        Returns:
        a DockerMachine that is a copy of this instance with the --storage-path option applied
      • tlsCACert

        public DockerMachine tlsCACert​(Object cert)
        Specify the CA to verify remotes against.

        Equates to the --tls-ca-cert command option.

        Parameters:
        cert - the cert
        Returns:
        a DockerMachine that is a copy of this instance with the --tls-ca-cert option applied
      • tlsCAKey

        public DockerMachine tlsCAKey​(Object key)
        Specify the private key to generate certificates.

        Equates to the --tls-ca-key command option.

        Parameters:
        key - the key
        Returns:
        a DockerMachine that is a copy of this instance with the --tls-ca-key option applied
      • tlsClientCert

        public DockerMachine tlsClientCert​(Object cert)
        Specify the client cert to use for TLS

        Equates to the --tls-client-cert command option.

        Parameters:
        cert - the cert
        Returns:
        a DockerMachine that is a copy of this instance with the --tls-client-cert option applied
      • tlsPrivateKey

        public DockerMachine tlsPrivateKey​(Object key)
        Specify the private key used in client TLS auth

        Equates to the --tls-client-key command option.

        Parameters:
        key - the key
        Returns:
        a DockerMachine that is a copy of this instance with the --tls-client-key option applied
      • githubToken

        public DockerMachine githubToken​(String token)
        Specify the token to use for requests to the Github API

        Equates to the --github-api-token command option.

        Parameters:
        token - the token
        Returns:
        a DockerMachine that is a copy of this instance with the --github-api-token option applied
      • nativeSSH

        public DockerMachine nativeSSH()
        Use the native (Go-based) SSH implementation

        Equates to the --native-ssh command option.

        Returns:
        a DockerMachine that is a copy of this instance with the --native-ssh option applied
      • bugSnagToken

        public DockerMachine bugSnagToken​(String token)
        Specify the BugSnag API token for crash reporting

        Equates to the --bugsnag-api-token command option.

        Parameters:
        token - the token
        Returns:
        a DockerMachine that is a copy of this instance with the --bugsnag-api-token option applied
      • getAddress

        public InetAddress getAddress​(String machineName)
        Obtain the InetAddress of the specified Docker Machine.

        The equivalent of running the Docker Machine ip command and turning the resulting address into an InetAddress.

        Parameters:
        machineName - the name of the Docker Machine to obtain the status for
        Returns:
        the status of the specified Docker Machine
      • create

        public DockerMachinePlatform create​(String machineName,
                                            com.oracle.bedrock.Option... options)
        Obtain a DockerMachinePlatform wrapping a new Docker Machine VM.
        Parameters:
        machineName - the name of the Docker Machine instance to create
        options - the Options and Arguments to pass to the create command
        Returns:
        a DockerMachinePlatform wrapping a new Docker Machine VM
      • launch

        public com.oracle.bedrock.runtime.Application launch​(String command,
                                                             com.oracle.bedrock.Option... options)
        Execute the specified DockerMachine command.
        Parameters:
        command - the command to execute
        options - the Options to use
        Returns:
        the Application executing the command
      • status

        public String status​(String machineName)
        Obtain the status of the specified Docker Machine.
        Parameters:
        machineName - the name of the Docker Machine to obtain the status for
        Returns:
        the status of the specified Docker Machine
      • inspect

        public javax.json.JsonObject inspect​(String machineName)
        Obtain the status of the specified Docker Machine.
        Parameters:
        machineName - the name of the Docker Machine to obtain the status for
        Returns:
        a JsonObject with the Docker Machine information
      • restart

        public int restart​(String... machineNames)
        Restart the specified Docker Machine instances.
        Parameters:
        machineNames - the name of the Docker Machine instance to restart
        Returns:
        the exit code from the restart command
      • remove

        public int remove​(boolean force,
                          String... machineNames)
        Remove the specified Docker Machine instances.
        Parameters:
        force - force removal or not
        machineNames - the name of the Docker Machine instance to remove
        Returns:
        the exit code from the remove command
      • stop

        public int stop​(String... machineNames)
        Stop the specified Docker Machine instances.
        Parameters:
        machineNames - the name of the Docker Machine instance to stop
        Returns:
        the exit code from the stop command
      • kill

        public int kill​(String... machineNames)
        Kill (abruptly force stop) the specified Docker Machine instances.
        Parameters:
        machineNames - the name of the Docker Machine instance to kill
        Returns:
        the exit code from the kill command
      • environmentFor

        public List<com.oracle.bedrock.runtime.options.EnvironmentVariable> environmentFor​(String machineName)
        Obtain the EnvironmentVariables that can be applied to a Docker command to make it execute against the specified Docker Machine.
        Parameters:
        machineName - the name of the Docker Machine
        Returns:
        the EnvironmentVariables required to use the Docker Machine
      • at

        public static DockerMachine at​(com.oracle.bedrock.runtime.Platform platform)
        Create a DockerMachine using the specified Platform as the platform to execute Docker Machine commands.
        Parameters:
        platform - the Platform
        Returns:
        a DockerMachine using the specified client Platform