Skip to content

fix: GATEWAY_URL host address differs between Docker and Podman #22

@kordless

Description

@kordless

Problem

The address a container uses to reach the host depends on the container runtime:

Runtime Platform Host address
Docker Desktop macOS/Windows host.docker.internal
Docker Engine Linux 172.17.0.1 (bridge IP) or host.docker.internal if extra-hosts set
Podman rootless Linux 10.0.2.2 (slirp4netns default)
Podman rootless macOS host.containers.internal
Podman rootful Linux 10.88.0.1 (podman bridge)

When injecting GATEWAY_URL (issue #19), nemesis8 must detect the runtime (already stored in DockerOps::runtime_binary) and platform to choose the right host address.

Fix

Add a gateway_host_address(runtime: &str) -> String helper in docker.rs that returns the correct host address. Use it when building GATEWAY_URL for spawned containers.

For Linux Docker without host.docker.internal, fall back to inspecting the container's default gateway via the Docker API or use --add-host=host.docker.internal:host-gateway in the run args.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions