createNetwork method

Future<String> createNetwork(
  1. String name, {
  2. Map<String, String> labels = const {},
})

Creates the bridge network name with labels and returns its id.

Containers of one such network reach each other by name (DockerContainerConfig.networkAliases), which the default bridge does not offer.

Implementation

Future<String> createNetwork(
  String name, {
  Map<String, String> labels = const {},
}) async {
  final body = await _json(
    await _send(
      'POST',
      '/networks/create',
      json: {
        'Name': name,
        'Driver': 'bridge',
        if (labels.isNotEmpty) 'Labels': labels,
      },
    ),
  );
  return '${body['Id']}';
}