findPort method

Future<int> findPort(
  1. String projectId,
  2. String service,
  3. int containerPort
)

Implementation

Future<int> findPort(
  String projectId,
  String service,
  int containerPort,
) async {
  final process = await io.Process.start('docker', [
    'compose',
    '-p',
    projectId,
    '-f',
    '-',
    'port',
    service,
    '$containerPort',
  ]);
  process.stdin.write(compose);
  await process.stdin.close();

  final output = await utf8.decodeStream(process.stdout);
  return int.parse(output.split(':').last);
}