command method

  1. @override
Future<DockerProcess> command(
  1. String command,
  2. List<String> args, {
  3. bool outputAsLines = true,
  4. int? outputLimit,
  5. OutputReadyFunction? stdoutReadyFunction,
  6. OutputReadyFunction? stderrReadyFunction,
  7. OutputReadyType? outputReadyType,
})
override

Executes an arbitrary Docker command with args.

Implementation

@override
Future<DockerProcess> command(
  String command,
  List<String> args, {
  bool outputAsLines = true,
  int? outputLimit,
  OutputReadyFunction? stdoutReadyFunction,
  OutputReadyFunction? stderrReadyFunction,
  OutputReadyType? outputReadyType,
}) async {
  var instanceID = DockerProcess.incrementInstanceID();

  outputReadyType ??= DockerHost.resolveOutputReadyType(
      stdoutReadyFunction, stderrReadyFunction);

  stdoutReadyFunction ??= (outputStream, data) => true;
  stderrReadyFunction ??= (outputStream, data) => true;

  var cmdArgs = [command, ...args];
  _log.info('docker command [CMD]>\t$dockerBinaryPath ${cmdArgs.join(' ')}');

  var process = await Process.start(dockerBinaryPath!, cmdArgs);

  var dockerProcess = DockerProcessLocal(
      this,
      instanceID,
      '',
      process,
      outputAsLines,
      outputLimit,
      stdoutReadyFunction,
      stderrReadyFunction,
      outputReadyType);

  _processes[instanceID] = dockerProcess;

  var ok = await _initializeAndWaitReady(dockerProcess);
  if (ok) {
    _log.info('Command[$ok]: $dockerProcess');
  }

  return dockerProcess;
}