Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/openshell-driver-docker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,12 @@ fn docker_gateway_route_for_host(
}
}

/// On macOS, Docker-compatible runtimes (Docker Desktop, Colima, Podman
/// machine, etc.) run Linux networking inside a VM. The bridge gateway IP is
/// therefore not assigned on the host interface where the gateway process
/// runs, so binding the gateway listener to that IP fails with
/// EADDRNOTAVAIL. Always route callbacks via host-gateway aliases on macOS
/// hosts, regardless of which runtime is detected.
fn host_runtime_requires_host_gateway_alias() -> bool {
cfg!(target_os = "macos")
}
Expand Down
25 changes: 25 additions & 0 deletions crates/openshell-driver-docker/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,31 @@ fn docker_gateway_route_uses_bridge_gateway_for_linux_docker() {
);
}

// Regression for macOS + OPENSHELL_DRIVERS=docker against a Podman-machine
// socket (OpenShell issue #1358): the daemon looks like generic Linux, but the
// bridge gateway IP only exists inside the VM. Binding it on the host fails
// with EADDRNOTAVAIL during gateway startup.
#[test]
#[cfg(target_os = "macos")]
fn docker_gateway_route_uses_host_gateway_for_podman_machine_on_macos() {
let info = SystemInfo {
// Observed values when docker CLI talks to podman machine API.
operating_system: Some("fedora".to_string()),
name: Some("localhost.localdomain".to_string()),
labels: None,
..Default::default()
};

let route = docker_gateway_route(
&info,
// Typical Podman machine bridge gateway; not routable on the macOS host.
IpAddr::V4(Ipv4Addr::new(10, 89, 0, 1)),
DEFAULT_SERVER_PORT,
None,
);
assert_eq!(route, DockerGatewayRoute::HostGateway);
}

#[test]
fn docker_gateway_route_uses_host_gateway_when_host_runtime_requires_it() {
let info = SystemInfo {
Expand Down
Loading