Coordinating HA and DB docker containers on different hosts

Question for the docker experts out there. I have HA running on a Pi w/ docker. I’m using postgres as my database, which is running in a docker container on a Synology NAS. This setup works great. However, I haven’t been able to figure out how to have HA depend on the postgres container in the same way that 2 containers can be linked when running on the same host. Is this a job for docker swarm? Is there some other way to have HA shuts down if the database goes down?