Class Commands


  • public class Commands
    extends Object
    Common Docker container commands.
    • Constructor Detail

      • Commands

        public Commands()
        Create with 'docker' as the command.
      • Commands

        public Commands​(String docker)
        Construct with explicit docker command.
    • Method Detail

      • stopIfRunning

        public void stopIfRunning​(String containerName)
        Stop the container checking to see if it is running first.
      • stopRemove

        public void stopRemove​(String containerName)
        Stop and remove the container.
      • remove

        public void remove​(String containerName)
        Remove the container.
      • start

        public void start​(String containerName)
        Start the container.
      • stop

        public void stop​(String containerName)
        Stop the container.
      • isRunning

        public boolean isRunning​(String containerName)
        Return true if the container is running.
      • isRegistered

        public boolean isRegistered​(String containerName)
        Return true if the container is registered (exists and maybe running or not).
      • logsContain

        public boolean logsContain​(String containerName,
                                   String match)
        Return true if the logs of the container contain the match text.
      • logs

        public List<Stringlogs​(String containerName)
        Return true if the logs of the container contain the match text.
      • registeredPortMatch

        public String registeredPortMatch​(String containerName,
                                          int matchPort)
        Check if the port matches the existing port bindings and if not return the existing port bindings.
      • logsContain

        public boolean logsContain​(String containerName,
                                   String logMessage,
                                   int tail)
        Return true if the container logs contains the logMessage.

        Usually used to find a log entry to indicate the container is ready for use.

        Parameters:
        containerName - The container logs to search
        logMessage - The logMessage we are looking for (to usually indicate the container is ready).
        tail - The number of logs to tail (such that we get recent and minimal logs)
        Returns:
        True if the logs searched contain the logMessage
      • logs

        public List<Stringlogs​(String containerName,
                                 int tail)
        Return the logs for the container with a tail.

        If tail = 0 then all logs are returned (but we should be careful using that).