Why my Node.js app can not connect to remote Postgres

Your friend is
docker exec -it container bash
Use that. I think you will see that the problem is in the name resolution of macmini.local. there are ways to expose an internal name like that to the container environment. You should not rely on the name resolution on the host but on the internal DNS server inside the docker environment.