stopByName method

  1. @override
Future<bool> stopByName(
  1. String name, {
  2. Duration? timeout,
})
override

Stops a container by name.

Implementation

@override
Future<bool> stopByName(String name, {Duration? timeout}) async {
  if (isEmptyString(name)) return false;

  var time = timeout != null ? timeout.inSeconds : 15;
  if (time < 1) time = 1;

  var process = Process.run(
      dockerBinaryPath!, <String>['stop', '--time', '$time', name]);
  var result = await process;
  return result.exitCode == 0;
}