During a routine check of a small price-tracking stack, the database and the scheduled jobs looked healthy, but its web view did not answer. The container behind it was running. Docker listed it as up. Nothing had crashed, and nothing in the stack was complaining. (The same check turned up a longer, quieter problem in the stack; that is a separate story.)
Running is not the same as reachable
The web container publishes its port on one specific address: the machine's mesh VPN address, not every interface. Inspecting the container showed that after the machine had booted the previous morning, its NetworkSettings.Ports was an empty list. The process was alive, but no port had been bound for it at all. A plain container restart brought the port back.
The explanation I wrote down at the time is a presumption, not a proof: at boot, Docker came up before the VPN had assigned its address, so the address the container asked for did not exist yet and the binding was skipped. The empty port list and the address-bound port point that way, but I did not reproduce the ordering, and nothing I recorded shows it directly.
Wait for the address, then check
The login agent that launched Docker now calls a short script instead. It waits up to five minutes for the VPN address to appear, then opens Docker, then looks at the container's port list and restarts the container only if that list is empty. It checks the address with ifconfig rather than the VPN's own command-line tool, because that tool has failed silently for me under launchd before. The agent was reinstalled by hand.
Its first run was clean: the address was there on the first check, Docker opened, the ports were in place, no restart, exit code zero. But that run happened on an already-running machine with the VPN long since up, which is exactly the situation where the race cannot occur. It shows the script works. It does not show that the script fixes the boot case. The real test is the next reboot: how many checks it took before the address appeared, and whether a restart was needed. As of writing, that reboot has not been verified.
A container that is up has only proven it is up; and a fix tested where the race cannot happen has not been tested against the race.