You are using
localhost address within the container which is not the same as your host's address. You should do one of the following instead:
- Use your actual host's IP from app's container
postgresdbcontainer's IP with the native port (5432). You can discover this IP using
docker inspect postgresdb.
postgresdbas host name and the native port (5432) when connecting both containers to the same network