connect static method
Finds the daemon (DockerEndpoint.resolve) and checks it answers.
Throws a DockerUnavailableException with the reason when it does not.
Implementation
static Future<DockerClient> connect({
Map<String, String>? environment,
}) async {
final endpoint = DockerEndpoint.resolve(environment: environment);
if (endpoint == null) {
throw DockerUnavailableException(
DockerEndpoint.unavailableReason(environment: environment) ??
'No Docker daemon found',
);
}
final client = DockerClient(endpoint);
try {
await client.ping();
} on Object {
client.close();
rethrow;
}
return client;
}