Skip to content

The job's localhost is the instance's (host networking) #39

Closed

Description

@sodre

User story

As a maintainer moving a job from ubuntu-latest to ci-runner, I want the job's localhost to be the instance's, so that a service the job starts in Docker (docker run -p, docker compose up, docker build --network host) is reachable at localhost:<port>, as it is on a GitHub-hosted runner.

Why

functions/cloud-config.js starts the runner container on Docker's default bridge network. The job runs in that container but drives the host's Docker daemon, so:

  • a port published with docker run -p 5432:5432 postgres is on the host's loopback, and localhost:5432 in the job is refused;
  • a server the job starts itself on 127.0.0.1 can't be reached by docker build --network host or docker run --network host, which use the host's loopback.

zae-zcm's readme-dockerfile job hit the second case. Its check serves a fake release download from the job and builds a Dockerfile against it. On ci-runner, curl in the build failed with Failed to connect to 127.0.0.1. The repo now works around it by serving the download from a host-network container, but every repo that moves a job with services will hit this.

It's the same gap the README already closes for files: /tmp and $HOME have the same paths in the container and on the host, so docker run -v works as on a GitHub-hosted runner. Host networking does the same for ports.

What it costs

  • Metadata service: the launch template's HttpPutResponseHopLimit: 1 stops a bridged container from reaching IMDS. With --network host the job container can reach it. That protects little today:
    • the instance has no instance profile, so IMDS holds no AWS credentials;
    • the sensitive part of the user-data is the JIT config, which the runner has already used by the time a job runs;
    • every job already has the Docker socket, so it can docker run --network host (or mount /) and get the same access anyway.
  • Ports: one job per instance, so nothing else competes for them.
  • Fargate: not affected; a task's containers already share localhost.

Acceptance criteria

  • The runner container starts with --network host.
  • A test job publishes a port with docker run -p and reaches it at localhost, and a server the job starts on 127.0.0.1 is reachable from docker build --network host.
  • The README's What the job gets says the job shares the instance's network, as it already does for /tmp and $HOME.
  • The launch template's IMDS comment says what the hop limit still protects, or IMDS is turned off once cloud-init has read the user-data.
  • The design spec (docs/superpowers/specs/2026-11-12-ci-runner-design.md, lines 213-214) no longer says that the Docker containers a job starts can't reach the instance metadata service: it says the containers a job starts with --network host can.

Activity

  1. added
    needs-triage
    ready-for-agent
    enhancement
    and removed
    needs-triage
    on Nov 14, 2026
  2. sodre commented on Nov 20, 2026

    @sodre
    MemberAuthor

    This was generated by AI during triage.

    Agent Brief

    Category: enhancement
    Summary: Make a job's localhost the instance's, so a service a job starts in Docker is reachable at localhost:<port>. The instance's metadata service is turned off once the boot configuration has read the user-data, so job containers cannot reach it.

    Current behavior:
    The runner container starts on Docker's default bridge network. A job's localhost is therefore the runner container's own. A port published with docker run -p lands on the instance's loopback and is refused at localhost. A server a job starts on 127.0.0.1 cannot be reached from docker build --network host. The instance's metadata service is reachable from job containers only through a hop limit of 1, set on the launch template and described as protecting it from job containers.

    Desired behavior:

    • The runner container shares the instance's network. A port published with docker run -p is reachable at localhost from the job. A server the job starts on 127.0.0.1 is reachable from docker build --network host and docker run --network host.
    • The instance's metadata service is disabled after the boot configuration has read the user-data. Nothing the instance or its jobs need after boot may depend on it. This is checked before the change ships, not assumed.
    • Each change to a documented security control is stated where the control is documented.
    • Fargate capacities are not changed. A task's containers already share localhost.

    Key interfaces:

    • The runner container's start command in the boot configuration: it gains host networking.
    • The launch template's metadata options: the metadata endpoint is disabled rather than limited to one hop. The launch version of the boot configuration must still read the user-data before the endpoint is off. The agent must confirm the order works on a real launch.
    • The README's "What the job gets" section: it says the job shares the instance's network, as it already does for /tmp and $HOME.
    • The comment on the launch template's metadata options: it states the new protection.

    Acceptance criteria:

    • The runner container starts with host networking. A test checks the start command.
    • The metadata service is disabled in the launch template. A test checks the launch template's metadata options.
    • A check confirms that nothing on the instance reads the metadata service after boot. The check and its result are stated in the pull request.
    • The README's "What the job gets" section says the job shares the instance's network.
    • The launch template's metadata comment says what is now protected, and that the job's containers cannot reach the metadata service because it is off.
    • The existing test suite passes.

    Out of scope:

    • Any change to Fargate capacities.
    • Any change to how the Docker socket is mounted, or to what jobs may do through it.
    • Any change to the label contract, the size and architecture rules, or the vCPU budgets.
    • Deciding whether the metadata service should come back for any other purpose. That is a separate question.
  3. self-assigned this
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementready-for-agent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions