Skip to content

[linux][P2] With -p, the guest cannot reach its own published service on 127.0.0.1:<guest_port> (listener is moved to the host, no native socket remains) #448

Closed

Description

@CharlieZiChen

Environment

  • A3S Box origin/main e06137de (v3.2.6), vendored libkrun daec6e8, libkrunfw v5.3.0; Linux 6.17, KVM, unprivileged user
  • Default TSI networking

Summary

In a default-mode box, publishing a port with -p host:guest removes the guest-side listener entirely: /proc/net/tcp
inside the guest has no LISTEN row, and a process inside the same box connecting to 127.0.0.1:<guest_port> gets
Connection refused. The only way for the guest to reach its own service is 127.0.0.1:<host_port> (proxied out to the
host and back in). Without -p the same image listens natively and 127.0.0.1:<guest_port> works (#378 behaviour).

Anything that talks to its own service on localhost — entrypoint readiness loops (pg_isready -h 127.0.0.1,
curl localhost:8080/health), app+sidecar images, in-container health checks, PostgreSQL clients started inside the box —
breaks as soon as the port is published, which is the one situation where users add -p.

Reproduction (3 fresh boxes, 6/6 refused)

a3s-box run -d --name n10 -p 18092:8080 linux-http-probe:current -- /http-fixture serve 0.0.0.0 8080
a3s-box exec n10 -- /http-fixture get 127.0.0.1 8080 /cl      # -> connect: Connection refused   (6/6)
a3s-box exec n10 -- /http-fixture get 127.0.0.1 18092 /cl     # -> 200 OK via host round-trip (fixture logs the request)
a3s-box exec n10 -- cat /proc/net/tcp                         # -> header only, no 0.0.0.0:1F90 LISTEN
curl http://127.0.0.1:18092/cl                                # -> 200 OK from the host

Control, same image without -p (3/3 boxes):

a3s-box exec n1 -- cat /proc/net/tcp                          # -> 00000000:1F90 … 0A  (LISTEN)
a3s-box exec n1 -- /http-fixture get 127.0.0.1 8080 /cl       # -> 200 OK, first_byte 0.12–0.17 ms

Earlier observed with postgres:16 published via -p: in-guest psql -h 127.0.0.1 fails while host psql succeeds.

Expected

Publishing a port makes the service reachable from the host in addition to inside the guest, as with Docker/Podman and
with Box bridge networking. At minimum, the limitation should be stated in the -p documentation and run should warn
(the existing warning only covers health checks probing localhost).

Notes

Under TSI try_listen the published guest listen() is satisfied by a host socket; #378 added the -EPERM native-listen
fallback for unpublished ports only. Keeping a native in-guest listener alongside the host listener for published ports
(or looping guest-origin connects to a published guest port back to the host listener) would restore Docker-equivalent
semantics.

Evidence: evidence/w11/n5/trial-{1,2,3}/run.log, guest-tcp.txt; control evidence/w11/n1/trial-{1,2,3}-user/guest-listeners.txt, guest-loopback-get.txt.

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