command method
Future<DockerProcess>
command(
- String command,
- List<
String> args, { - bool outputAsLines = true,
- int? outputLimit,
- OutputReadyFunction? stdoutReadyFunction,
- OutputReadyFunction? stderrReadyFunction,
- 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;
}