exec method
Future<DockerProcess?>
exec(
- String containerName,
- String command,
- List<
String> args, { - bool? outputAsLines = true,
- int? outputLimit,
- OutputReadyFunction? stdoutReadyFunction,
- OutputReadyFunction? stderrReadyFunction,
- OutputReadyType? outputReadyType,
override
Executes a command
inside containerName
with args
.
Implementation
@override
Future<DockerProcess?> exec(
String containerName,
String command,
List<String> args, {
bool? outputAsLines = true,
int? outputLimit,
OutputReadyFunction? stdoutReadyFunction,
OutputReadyFunction? stderrReadyFunction,
OutputReadyType? outputReadyType,
}) async {
if (isContainerARunner(containerName)) {
if (!isContainerRunnerRunning(containerName)) return null;
} else {
var running = await isContainerRunning(containerName);
if (!running) return null;
}
var instanceID = DockerProcess.incrementInstanceID();
outputReadyType ??= DockerHost.resolveOutputReadyType(
stdoutReadyFunction, stderrReadyFunction);
stdoutReadyFunction ??= (outputStream, data) => true;
stderrReadyFunction ??= (outputStream, data) => true;
var cmdArgs = ['exec', containerName, command, ...args];
_log.info('docker exec [CMD]>\t$dockerBinaryPath ${cmdArgs.join(' ')}');
var process = await Process.start(dockerBinaryPath!, cmdArgs);
var dockerProcess = DockerProcessLocal(
this,
instanceID,
containerName,
process,
outputAsLines,
outputLimit,
stdoutReadyFunction,
stderrReadyFunction,
outputReadyType);
_processes[instanceID] = dockerProcess;
var ok = await _initializeAndWaitReady(dockerProcess);
if (ok) {
_log.info('Exec[$ok]: $dockerProcess');
}
return dockerProcess;
}