Skip to content

Container port links always point at localhost, even for remote hosts #157

Description

@rodriguecyber

Difficulty: Beginner · You'll need: TypeScript, React · Size: ~15 lines

What's going on

apps/web/src/components/ContainerTable.tsx:280 turns the published port into a link:

<Link target="_blank" to={`http://localhost:${container.ports[0]?.PublicPort}`}>

The hostname is hardcoded to localhost.

Why it matters

DockSight exists to manage containers on remote hosts — that is the entire premise of the outbound-agent design. A container on a data-centre host publishing :8080 renders a link to http://localhost:8080, which either 404s or, worse, opens something unrelated running on the operator's own machine.

The link is only correct in the single case where the operator is browsing the dashboard from the same machine the container runs on.

Additional problems in the same expression

  • ports[0] silently picks the first mapping. A container publishing three ports shows one link with no indication the others exist.
  • The scheme is hardcoded to http://, so an HTTPS service gets a broken link.
  • PublicPort is empty for containers that expose a port without publishing it, producing http://localhost:.

Things to work out

The dashboard does not currently know a host's reachable address. HostCard and the hosts API expose hostname, but that is the machine's own hostname as reported by the agent, which is not necessarily resolvable or routable from the operator's browser.

Options, roughly in order of effort:

  1. Drop the link. Render the port text only. Honest, and strictly better than a wrong link.
  2. Link only when the host is reachable. Requires the platform to know a browsable address per host — a new field operators set, since it cannot be inferred.
  3. Show all mappings. A small popover listing every published port, linked where a host address is known.

Option 1 is a safe immediate fix; 2 and 3 need a decision on where a host address comes from.

Done when

  • No link points at localhost for a container on a remote host
  • Containers publishing multiple ports do not silently hide mappings
  • A container with no published port renders no link

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:webThe React dashboard (apps/web)bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions