public void dumpLog(String containerId,File logFile) throws DockerException, InterruptedException {
  LogStream errorStream=null;
  FileChannel fileChannel=null;
  FileOutputStream fileOutputStream=null;
  try {
    if (logFile.exists()) {
      logFile.delete();
    }
    logFile.createNewFile();
    fileOutputStream=new FileOutputStream(logFile);
    fileChannel=fileOutputStream.getChannel();
    errorStream=dockerClient.logs(containerId,LogsParam.stderr());
    while (errorStream.hasNext()) {
      LogMessage message=errorStream.next();
      ByteBuffer buffer=message.content();
      fileChannel.write(buffer);
    }
  }
 catch (  FileNotFoundException e) {
    throw new DockerException("File " + logFile + " not found");
  }
catch (  IOException e) {
    throw new DockerException(e);
  }
 finally {
    if (errorStream != null) {
      errorStream.close();
    }
    if (fileChannel != null) {
      try {
        fileChannel.close();
      }
 catch (      IOException e) {
        logger.error("Failed to close file channel",e);
      }
    }
    if (fileOutputStream != null) {
      try {
        fileOutputStream.close();
      }
 catch (      IOException e) {
        logger.error("Failed to close file output stream",e);
      }
    }
  }
}

public void dumpLog ( String containerId , File logFile ) throws DockerException , InterruptedException { LogStream errorStream = null ; FileChannel fileChannel = null ; FileOutputStream fileOutputStream = null ; try { if ( logFile . exists ( ) ) { logFile . delete ( ) ; } logFile . createNewFile ( ) ; fileOutputStream = new FileOutputStream ( logFile ) ; fileChannel = fileOutputStream . getChannel ( ) ; errorStream = dockerClient . logs ( containerId , LogsParam . stderr ( ) ) ; while ( errorStream . hasNext ( ) ) { LogMessage message = errorStream . next ( ) ; ByteBuffer buffer = message . content ( ) ; fileChannel . write ( buffer ) ; } } catch ( FileNotFoundException e ) { throw new DockerException ( "File " + logFile + " not found" ) ; } catch ( IOException e ) { throw new DockerException ( e ) ; } finally { if ( errorStream != null ) { errorStream . close ( ) ; } if ( fileChannel != null ) { try { fileChannel . close ( ) ; } catch ( IOException e ) { logger . error ( "Failed to close file channel" , e ) ; } } if ( fileOutputStream != null ) { try { fileOutputStream . close ( ) ; } catch ( IOException e ) { logger . error ( "Failed to close file output stream" , e ) ; } } } }
helper method for dumping error logs from docker to file
