mtoolstec on X runs magpie in LazyCat (懒猫微服) and, with "Share on
local network" on, Settings offered http://172.28.3.65:3425: the
container's own address, which nothing outside the box reaches, and no
hint that it was a container's.
LazyCat injects LAZYCAT_APP_DOMAIN (magpie.<box>.heiyu.space) into every
container of an app and serves the app there over HTTPS. The
magpie-lzcapp package sets MAGPIE_PUBLIC_URL=https://{{.S.AppDomain}}
through a manifest template, which only lzcos 1.3.8+ renders; unrendered,
url.Parse refuses the "{" host and publicURL() was "" (the log says
"ignoring invalid MAGPIE_PUBLIC_URL"). A hand-written manifest may not
set it at all. Then ContainerAddrs() needed inContainer(), which knew
only Docker's and Podman's marker files and a runtime's name in PID 1's
cgroup. Under cgroup v2 with a private cgroup namespace (Docker's
default since 20.10) /proc/1/cgroup is "0::/", and a runtime that writes
no marker file got past it, so the container's addresses were listed as
the computer's.
- publicURL() falls back to https://$LAZYCAT_APP_DOMAIN when
MAGPIE_PUBLIC_URL is unset or invalid (a DNS name only; lower-cased).
Everything built on PublicURL follows: LANURLs, PublicHost (the
rebinding Host check), magpie web's links and trusted origin, the
image MCP base, the CLI's advertised URL. InContainer() is true there
too (updates go through the image).
- inContainer() also takes a container's init as PID 1 (magpie itself,
as our image starts it; tini, docker-init, dumb-init, catatonit), and
a cgroup namespace's root ("0::/") on an overlay root filesystem
(/proc/1/mountinfo). Neither alone catches a host: a systemd host is
in /init.scope even on a read-only overlay root, and an init without
cgroups on ext4/btrfs is not overlay. hostNetwork is unchanged, so a
container on the host's network still lists the host's addresses.
What the user sees: in LazyCat, "Share on local network" shows
https://magpie.<box>.heiyu.space (and the Gateway URL is that domain).
In any other cgroup v2 container on a bridge network without a marker
file, Settings shows the container hint to set MAGPIE_PUBLIC_URL.
Run:
- TestInContainer (13 fake roots: systemd host, systemd on overlayroot,
cgroup-less init on btrfs, WSL, markers, cgroup v1, kubepods, cgroup v2
on overlay, magpie/docker-init/tini as PID 1) and TestLazyCatPublicURL
(LazyCat domain, mixed case, the unrendered template, MAGPIE_PUBLIC_URL
winning, bad domains) pass on Linux (wsl-run, magpie-desktop).
- Broken by hand: with origin/main's lan.go both tests are red (4 and 4
cases).
- Real systems: the WSL2 distro (systemd host, 0::/init.scope) reads
inContainer=false. Docker 28.2.2 on xiaomi-gpu, debian:12-slim with
/.dockerenv removed (cgroup "0::/", overlay root, PID 1 sh) reads
inContainer=true hostNetwork=false; with --init (docker-init) true;
with --network host inContainer=true hostNetwork=true, so it still
isn't called a container's addresses.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./..., and the darwin/linux nogui/windows builds pass on mote at
the first base (ddd6c649b); after the rebase onto 7 newer main commits,
go vet ./internal/..., linux and windows vet of gateway/gui/cli and the
build pass on mote.
- Linux (wsl-run): internal/gateway ok (1230s) at the rebased head;
internal/cli (1707s) and internal/gui (624s), -tags nogui, ok at the
first base.
- Not run: the full ./... suite. It was queued on mote's suite.lock
behind ~15 other sessions' runs for 46 minutes and I stopped it; CI
runs it on this push. No GUI file changed.
Not tried: a real LazyCat box (none here); the env names and the
https domain are from developer.lazycat.cloud/advanced-envs and the
lazycat-contrib/magpie-lzcapp manifest.
- After a last rebase onto fdd38154b (6 commits in usage, library,
providers, settings and docs; none in internal/gateway), nothing was
run again.