Repository navigation
Conversation
…restart "Expose to host" published every port on 0.0.0.0. The host IP was a literal in ployer-docker's create_container, so there was no way to ask for anything else — a database installed from the dashboard was reachable from the LAN, from any VPN the host had joined, and from the internet if the router forwarded the port. Docker publishes through its own DOCKER iptables chain, which ufw does not filter, so adding a firewall rule afterwards would not have closed it either. Published ports now carry the interface they are bound to: - `BindAddress` (Loopback | AllInterfaces | Address) defaults to Loopback. - `ContainerConfig.ports` maps a container port to a `PublishedPort` (bind + host port) instead of a bare host-port string. - The install form, the application's expose toggle and POST /containers all take an optional `bind`; omitted means loopback. - The chosen interface is written into the stored compose as a three-part spec (`127.0.0.1:15432:5432`), so it survives a redeploy and can be read back. `parse_port_spec` replaces the old split-on-first-colon, which read "127.0.0.1:15432:5432" as host port "127.0.0.1". - Every published port is announced in the deploy log, with a warning when it is not loopback-only. Applications deployed from git are loopback-bound too. They publish on an ephemeral port that only Caddy uses, and Caddy runs on the host and proxies to localhost, so nothing about the reverse proxy path changes. Behaviour change: a compose written before this names no interface, so the next redeploy of an already-installed service moves it from 0.0.0.0 to 127.0.0.1. Re-pick "All interfaces" on the application page to keep LAN access; the redeploy then writes the interface out explicitly. Running containers are untouched until they are redeployed. Separately, the template's declared `restart:` was parsed and then discarded — deployment.rs passed None and ployer-docker mapped None to "unless-stopped", so a template asking for `restart: "no"` silently got "unless-stopped". The compose path now passes the declared value through, "on-failure:5" keeps its retry cap, and an unrecognised policy is an error instead of a silent fallback to unless-stopped. No declaration still means "unless-stopped". Tests: ployer-docker 6 -> 20, ployer-templates 6 -> 25, workspace 143 -> 176. The bind address had no coverage at all before. Four mutations were checked: Loopback->0.0.0.0 (4 tests fail), unspecified host IP->AllInterfaces (1), unknown restart policy falling back silently (1), and dropping the interface in parse_port_spec / add_ports_to_all_services (2 and 6).
|
Heads-up on a cross-PR break, the kind DOCUMENTATION.md warns about: each PR is green on its own head, and #10 (bind published ports to loopback by default) adds a Two things in
Worth adding while you are in there: No action needed yet; just so neither of us merges into a red |
What
Ticking "Expose to host" published the port on
0.0.0.0— every interface — with no way to ask for anything else. The host IP was a literal inployer-docker:On the reporting host that meant PostgreSQL, MariaDB (3306), MongoDB (27017) and Jellyfin (8096) were all reachable from the LAN and the tailnet, with no host firewall.
pg_stat_activityshowed live sessions from another machine on the LAN. Docker publishes through its ownDOCKERiptables chain, so aufwrule added afterwards would not have closed it.Published ports now carry the interface they are bound to, and that interface defaults to loopback.
How
ployer-dockerBindAddress—Loopback(127.0.0.1, theDefault) |AllInterfaces(0.0.0.0) |Address(String)for a specific interface such as a tailnet IP.ContainerConfig.portsis nowHashMap<String, PublishedPort>(bind + host port) instead ofHashMap<String, String>. Per-port rather than per-container, because that is how Docker models it and because it round-trips a compose file losslessly.build_port_bindingsis split out ofcreate_containerand pure, so the interface a port lands on is assertable without a Docker daemon.ployer-templatesparse_port_specreplaces splitting on the first colon, which read127.0.0.1:15432:5432as host port127.0.0.1and container port15432:5432. It handlescontainer,host:container,ip:host:containerand bracketed IPv6.split_portstays as a thin wrapper for callers that do not care about the interface.add_ports_to_all_servicestakes the interface and always writes it out, so the stored compose records the choice instead of leaving it to whatever the deployer's default happens to be.API —
POST /templates/:slug/install,PUT /applications/:id/exposeandPOST /containerstake an optionalbind. Omitted means loopback. Theportswire shape onPOST /containersis unchanged.Deploy path — the compose path reads the interface back out of each port spec and announces every published port in the deploy log, with a warning when it is not loopback-only. Applications deployed from git are loopback-bound on their ephemeral port; Caddy runs on the host and proxies to
localhost, so the reverse proxy path is unaffected.UI — "Expose to host" gains a "Reachable from" choice (this host only / all interfaces), on both the install form and the application page. Choosing all interfaces shows a warning, with sharper wording for
category: database. The application page reads the current interface out of the stored compose, so the form shows what is actually running.Breaking change
A redeploy of an already-exposed service moves it from
0.0.0.0to127.0.0.1. Compose files written before this name no interface, and no interface means the default.This is deliberate — a security fix that only applies to new installs would leave every service already on the host exposed, which is the actual reported problem. Nothing happens until the service is redeployed; running containers are untouched. To keep LAN access, pick "All interfaces" on the application's page and save; the redeploy writes the interface into the compose explicitly, so it sticks.
To reach a loopback-bound service from another machine without republishing it:
Also a public API change inside the workspace:
ContainerConfig.portschanges type andadd_ports_to_all_servicestakes an extra argument. Both are internal crates with no external consumers; all call sites are updated here.Related:
restart:was parsed and discardedThe audit recorded the template's
restart:as "parsed then discarded", which was half the story.deployment.rspassedrestart: Noneandployer-dockermappedNoneto"unless-stopped", so the live container genuinely wasunless-stopped— but a template asking forrestart: "no"would have silently gotunless-stoppedtoo.The compose path now passes the declared value through.
on-failure:5keeps its retry cap. An unrecognised policy is an error instead of falling through tounless-stopped— a typo in a template should fail the install loudly. No declaration still meansunless-stopped, so git-deployed apps and every existing template are unchanged.Verification
SQLX_OFFLINE=truefor every cargo command, per DOCUMENTATION.md.ployer-dockerhad 6 tests and none covered the bind address; it has 20.ployer-templatesgoes 6 -> 25. Four mutations were introduced and reverted to check the tests actually bite:Loopbackresolves to0.0.0.0AllInterfacesunless-stoppedparse_port_specdrops the interfaceadd_ports_to_all_servicesdrops the interfaceNot covered
The one-line wiring in
deployment.rsthat passesservice.restarttoContainerConfigis not pinned by a test.ployer-apiis a binary crate with no lib target, so there is nowhere to put an integration test for the compose deploy path without restructuring the crate — out of scope here. Both ends are covered (the compose parser keepsrestart, andployer-dockerhonours it); only the wire between them is not.Nothing was deployed and no running container was touched.