I'm a beginner at docker and new to docker-compose. I am trying to get a project running with docker compose. When My backend app tries to connect to the db, I get this error:
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Can you see anything wrong with my compose file that could cause it to not connect?
version: "3"
services:
db:
image: postgres
volumes:
- data-volume:/var/lib/db
ports:
- "5432"
backup:
image: ubuntu
volumes:
- data-volume:/var/lib/backup/data
backend:
image: java
restart: always
volumes:
- data-volume:/var/lib/backup/data
- ~/code/myCode:/usr/src/app/
command: sh /usr/src/app/Docker/docker-setup.sh
expose:
- "8000"
volumes:
data-volume:
- "5432:5432"?