containerHostIp method
Returns the host IP address through which this container is reachable.
Delegates to DockerClient.connectionMode and then queries the appropriate address (DockerClient.host, DockerClient.gatewayIp, or DockerClient.bridgeIp).
Implementation
@override
Future<String> containerHostIp() async {
final mode = _dockerClient.connectionMode;
if (_containerId == null) {
return 'localhost';
}
return switch (mode) {
ConnectionMode.dockerHost => _dockerClient.host,
ConnectionMode.gatewayIp => _dockerClient.gatewayIp(_requireContainerId),
ConnectionMode.bridgeIp => _dockerClient.bridgeIp(_requireContainerId),
};
}