Container domain names (name.krane.local) #15

Open
opened 2026-11-30 14:39:42 +00:00 by jfro · 1 comment
Owner

OrbStack gives each container a name like name.orb.local (with HTTPS). On Linux container IPs are already reachable, so Krane could add names without a VM.

What (to discuss before building)

  • Resolve <container>.krane.local and <service>.<project>.krane.local to container IPs, e.g. by registering with systemd-resolved over D-Bus (per-link DNS domain) or a tiny local DNS responder.
  • Show the domain on the container and make "open in browser" use it.
  • Optional, later: HTTPS via a local CA and a reverse proxy container.

Notes

  • Touches system DNS settings and may need polkit; only works for a local engine. Needs a design decision first.
OrbStack gives each container a name like `name.orb.local` (with HTTPS). On Linux container IPs are already reachable, so Krane could add names without a VM. **What (to discuss before building)** - Resolve `<container>.krane.local` and `<service>.<project>.krane.local` to container IPs, e.g. by registering with systemd-resolved over D-Bus (per-link DNS domain) or a tiny local DNS responder. - Show the domain on the container and make "open in browser" use it. - Optional, later: HTTPS via a local CA and a reverse proxy container. **Notes** - Touches system DNS settings and may need polkit; only works for a local engine. Needs a design decision first.
jfro added this to the v1.0 milestone 2026-11-30 14:47:14 +00:00
Author
Owner

Design research for this issue (by Nye, our reviewer, tested on a real Debian 13 box with systemd-resolved). Building waits on the three calls at the end.

Tested on Debian 13, systemd 257, resolved active, nss-mdns active, Docker local.
Prototype responder (40 lines, stdlib) is in the collapsed block at the bottom.

What I proved on a real box

  • A user-run DNS responder on an unprivileged port (10.253.53.1:5380 on a dummy link krane0),
    registered with resolved via SetLinkDNSEx (port supported) + SetLinkDomains(~krane.local, ~krane.internal)
    • SetLinkDefaultRoute(false): getent/resolvectl resolve web.krane.local, api.shop.krane.local,
      web.krane.internal; unknown names NXDOMAIN; normal DNS untouched.
  • nsswitch here has mdns4_minimal [NOTFOUND=return], yet 3-label .local names still reached resolved
    (nss-mdns >= 0.14 only claims 2-label names). So <c>.krane.local works; old nss-mdns could break it.
  • As a normal user, SetLinkDNSEx fails: "Interactive authentication required" (polkit
    set-dns-servers / set-domains = auth_admin_keep for active sessions -> password prompt every login).
  • docker0 as the link: resolved ignores it while no container is on docker0 (NO-CARRIER, scopes: none),
    so compose-network containers would not resolve. Use a dummy link instead.
  • resolved keeps per-link settings across its own restart; they're lost on reboot (link gone).

Options

(a) Krane registers per-link DNS over D-Bus (zbus, already in Cargo.lock via ksni) at every start.
Runtime: create/find link, call SetLinkDNSEx/Domains. Needs: root to create the dummy link AND
polkit auth each login (or a polkit rule installed once, which can't be scoped to one link).
Breaks: autostart (prompt at login). Code: small, but privilege story is bad.
(b) One-time privileged setup + unprivileged responder (RECOMMENDED).
Setup (pkexec, from a Settings button, once): install krane-dns.service (oneshot, root) that runs
ip link add krane0 type dummy; ip addr add 10.253.53.1/32 dev krane0; ip link set krane0 up; resolvectl dns krane0 10.253.53.1:5380; resolvectl domain krane0 '~krane.local'; resolvectl default-route krane0 false, plus NetworkManager unmanaged-devices=interface-name:krane0.
Runtime: Krane binds UDP+TCP 10.253.53.1:5380 (no privilege), answers A/AAAA from the bollard
container list + events (<name>.krane.local, compose labels -> <service>.<project>.krane.local),
NXDOMAIN otherwise, TTL ~5s. Krane down -> names fail fast, nothing else affected.
Needs: systemd-resolved. Without it (Debian desktop default, Arch unless enabled, Alpine/musl):
Settings shows "needs systemd-resolved" and the feature stays off; no resolv.conf edits.
Code: responder ~200 lines on hickory-proto (well used) or simple-dns (small) for parsing;
name map from existing engine data; setup script ~30 lines; zbus read-only check of
org.freedesktop.resolve1 Link "krane0" DNS to show enabled/disabled. About half a day for Dev.
(c) Simpler alternatives, rejected: /etc/hosts (root on every change); NSS module (root install,
C ABI, skipped by apps that use their own resolver); dnsmasq/NM-dnsmasq drop-ins (distro-specific,
not on by default). Running the responder in a container on a Krane bridge network avoids the
dummy link but needs an image pull and a docker.sock mount; not worth it.

Recommendation and v1.0 scope

Go with (b). v1.0 scope:

  1. Settings: "Domain names" toggle -> one-time pkexec setup (and an undo that removes the unit/link).
  2. Responder for <container>.krane.local and <service>.<project>.krane.local (A, AAAA if IPv6 IP).
  3. Show the domain in container detail; "Open in browser" uses http://:.
  4. Off for remote DOCKER_HOST and rootless Docker (container IPs not reachable from host).
  5. --mock: show domains in mock data/screenshots.
    Out of scope: HTTPS/local CA/reverse proxy, port-less URLs, non-resolved distros.

Calls for Jeremy

  • Suffix: .krane.local (matches the issue/OrbStack; worked here) vs .krane.internal
    (ICANN-reserved for private use in 2024; no mDNS edge cases). Lean: .krane.local, both work.
  • OK with a one-time pkexec setup (installs a root systemd unit) for this feature?
  • Address for krane0: 10.253.53.1/32 (could collide with a VPN) vs 169.254.53.53 link-local.

Not tried

NetworkManager-managed host (does NM leave krane0's resolved config alone without the unmanaged
drop-in?), Fedora/Ubuntu, Firefox/Chrome with DoH on, IPv6.

Calls needed from @jfro

  1. Suffix: .krane.local or .krane.internal?
  2. OK with a one-time pkexec setup that installs a root systemd unit (krane-dns.service)?
  3. krane0 address: 10.253.53.1/32 or 169.254.53.53?
Prototype responder (issue15-proto-dns.py)
import socket,struct,sys
host,port=sys.argv[1],int(sys.argv[2])
NAMES={"web.krane.local":"172.17.0.9","web.krane.internal":"172.17.0.9","api.shop.krane.local":"172.17.0.10"}
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM);s.bind((host,port))
while True:
    d,a=s.recvfrom(512); tid,fl,qd=struct.unpack(">HHH",d[:6]); i=12;labels=[]
    while d[i]: labels.append(d[i+1:i+1+d[i]].decode()); i+=1+d[i]
    q=d[12:i+5]; qt=struct.unpack(">H",d[i+1:i+3])[0]; name=".".join(labels).lower()
    ip=NAMES.get(name); print("Q",name,qt,a,flush=True)
    if ip and qt==1:
        ans=b"\xc0\x0c"+struct.pack(">HHIH",1,1,5,4)+socket.inet_aton(ip); hdr=struct.pack(">HHHHHH",tid,0x8580,1,1,0,0)
    else:
        ans=b""; hdr=struct.pack(">HHHHHH",tid,0x8580 if ip else 0x8583,1,0,0,0)
    s.sendto(hdr+q+ans,a)
Design research for this issue (by Nye, our reviewer, tested on a real Debian 13 box with systemd-resolved). Building waits on the three calls at the end. Tested on Debian 13, systemd 257, resolved active, nss-mdns active, Docker local. Prototype responder (40 lines, stdlib) is in the collapsed block at the bottom. ## What I proved on a real box - A user-run DNS responder on an unprivileged port (10.253.53.1:5380 on a dummy link `krane0`), registered with resolved via SetLinkDNSEx (port supported) + SetLinkDomains(~krane.local, ~krane.internal) + SetLinkDefaultRoute(false): `getent`/`resolvectl` resolve web.krane.local, api.shop.krane.local, web.krane.internal; unknown names NXDOMAIN; normal DNS untouched. - nsswitch here has `mdns4_minimal [NOTFOUND=return]`, yet 3-label .local names still reached resolved (nss-mdns >= 0.14 only claims 2-label names). So `<c>.krane.local` works; old nss-mdns could break it. - As a normal user, SetLinkDNSEx fails: "Interactive authentication required" (polkit set-dns-servers / set-domains = auth_admin_keep for active sessions -> password prompt every login). - docker0 as the link: resolved ignores it while no container is on docker0 (NO-CARRIER, scopes: none), so compose-network containers would not resolve. Use a dummy link instead. - resolved keeps per-link settings across its own restart; they're lost on reboot (link gone). ## Options (a) Krane registers per-link DNS over D-Bus (zbus, already in Cargo.lock via ksni) at every start. Runtime: create/find link, call SetLinkDNSEx/Domains. Needs: root to create the dummy link AND polkit auth each login (or a polkit rule installed once, which can't be scoped to one link). Breaks: autostart (prompt at login). Code: small, but privilege story is bad. (b) One-time privileged setup + unprivileged responder (RECOMMENDED). Setup (pkexec, from a Settings button, once): install `krane-dns.service` (oneshot, root) that runs `ip link add krane0 type dummy; ip addr add 10.253.53.1/32 dev krane0; ip link set krane0 up; resolvectl dns krane0 10.253.53.1:5380; resolvectl domain krane0 '~krane.local'; resolvectl default-route krane0 false`, plus NetworkManager `unmanaged-devices=interface-name:krane0`. Runtime: Krane binds UDP+TCP 10.253.53.1:5380 (no privilege), answers A/AAAA from the bollard container list + events (`<name>.krane.local`, compose labels -> `<service>.<project>.krane.local`), NXDOMAIN otherwise, TTL ~5s. Krane down -> names fail fast, nothing else affected. Needs: systemd-resolved. Without it (Debian desktop default, Arch unless enabled, Alpine/musl): Settings shows "needs systemd-resolved" and the feature stays off; no resolv.conf edits. Code: responder ~200 lines on `hickory-proto` (well used) or `simple-dns` (small) for parsing; name map from existing engine data; setup script ~30 lines; zbus read-only check of org.freedesktop.resolve1 Link "krane0" DNS to show enabled/disabled. About half a day for Dev. (c) Simpler alternatives, rejected: /etc/hosts (root on every change); NSS module (root install, C ABI, skipped by apps that use their own resolver); dnsmasq/NM-dnsmasq drop-ins (distro-specific, not on by default). Running the responder in a container on a Krane bridge network avoids the dummy link but needs an image pull and a docker.sock mount; not worth it. ## Recommendation and v1.0 scope Go with (b). v1.0 scope: 1. Settings: "Domain names" toggle -> one-time pkexec setup (and an undo that removes the unit/link). 2. Responder for `<container>.krane.local` and `<service>.<project>.krane.local` (A, AAAA if IPv6 IP). 3. Show the domain in container detail; "Open in browser" uses http://<domain>:<first exposed port>. 4. Off for remote DOCKER_HOST and rootless Docker (container IPs not reachable from host). 5. --mock: show domains in mock data/screenshots. Out of scope: HTTPS/local CA/reverse proxy, port-less URLs, non-resolved distros. ## Calls for Jeremy - Suffix: `.krane.local` (matches the issue/OrbStack; worked here) vs `.krane.internal` (ICANN-reserved for private use in 2024; no mDNS edge cases). Lean: .krane.local, both work. - OK with a one-time pkexec setup (installs a root systemd unit) for this feature? - Address for krane0: 10.253.53.1/32 (could collide with a VPN) vs 169.254.53.53 link-local. ## Not tried NetworkManager-managed host (does NM leave krane0's resolved config alone without the unmanaged drop-in?), Fedora/Ubuntu, Firefox/Chrome with DoH on, IPv6. ## Calls needed from @jfro 1. Suffix: `.krane.local` or `.krane.internal`? 2. OK with a one-time pkexec setup that installs a root systemd unit (krane-dns.service)? 3. krane0 address: `10.253.53.1/32` or `169.254.53.53`? <details><summary>Prototype responder (issue15-proto-dns.py)</summary> ```python import socket,struct,sys host,port=sys.argv[1],int(sys.argv[2]) NAMES={"web.krane.local":"172.17.0.9","web.krane.internal":"172.17.0.9","api.shop.krane.local":"172.17.0.10"} s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM);s.bind((host,port)) while True: d,a=s.recvfrom(512); tid,fl,qd=struct.unpack(">HHH",d[:6]); i=12;labels=[] while d[i]: labels.append(d[i+1:i+1+d[i]].decode()); i+=1+d[i] q=d[12:i+5]; qt=struct.unpack(">H",d[i+1:i+3])[0]; name=".".join(labels).lower() ip=NAMES.get(name); print("Q",name,qt,a,flush=True) if ip and qt==1: ans=b"\xc0\x0c"+struct.pack(">HHIH",1,1,5,4)+socket.inet_aton(ip); hdr=struct.pack(">HHHHHH",tid,0x8580,1,1,0,0) else: ans=b""; hdr=struct.pack(">HHHHHH",tid,0x8580 if ip else 0x8583,1,0,0,0) s.sendto(hdr+q+ans,a) ``` </details>
jfro removed this from the v1.0 milestone 2026-11-30 15:02:34 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/krane#15
No description provided.