I have a container stack (specified by a docker-compose.yml). The stack requires a PostgreSQL database, but I am using a locally running native instance instead of having it be a part of the stack (to make e.g. backups easier, and to conserve resources). The PostgreSQL instance is set to bind and listen on 172.17.0.1, the IP under which the host is reachable from within docker containers.
However, during system startup, PostgreSQL doesn't bind to that address, and the containers subsequently fail to initialize. If I restart PostgreSQL afterwards, I can see it's bound (via ss), and the containers initialize fine. This is 100% reproducible on every boot.
I think it's because the interface doesn't exist yet, so there's nothing to bind to. Is there a way to "persist" the network (or the interface) so that it can be bound to even while docker hasn't initialized yet?
(I've also tried specifying After=docker.service in the systemd service file for PostgreSQL, with no luck - I think it's because while docker has already initialized, the container stacks haven't, and so the networks haven't been yet created either. Specifying "wait until a docker container has started" in systemd is impossible as far as I'm aware.)