startImpl method

  1. @override
Future<bool> startImpl()
override

The start implementation.

Implementation

@override
Future<bool> startImpl() async {
  _started = false;

  var dockerCommander = DockerCommander(dockerHost);

  await dockerCommander.ensureInitialized();

  var daemonOk = await dockerCommander.isDaemonRunning();
  if (!daemonOk) {
    throw StateError("Docker Daemon not running!");
  }

  _log.info('** Creating container... >> $this');

  var container = this.container = await createContainer(dockerCommander);

  var ready = await container.waitReady();
  if (!ready) {
    throw StateError("Container not ready!");
  }

  _started = true;

  var logsStdout = container.stdout?.asString;
  var logsStderr = container.stderr?.asString;

  _log.info('Container $container LOGS:\n'
      '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< [LOGS STDOUT]\n'
      '$logsStdout\n'
      '======================================================== [LOGS STDERR]\n'
      '$logsStderr\n'
      '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [LOGS END]');

  _log.info('** STARTED> $this');

  return true;
}