I create an sample java project with springboot data and postgres. I started to make my docker-compose but i can't link my database to my application...
I have this error
web_1 | org.postgresql.util.PSQLException: Connection to localhost:5438 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
On my application ressource
server:
port: 4000
spring:
datasource:
platform: postgres
url: jdbc:postgresql://localhost:5438/acronym
username: acronym
password: acronym1234
driver-class-name: org.postgresql.Driver
jpa:
database: POSTGRESQL
show-sql: true
generate-ddl: true
hibernate:
ddl-auto: create
and my docker compose file
version: '3.3'
services:
web:
image: acronym:latest
ports:
- 4000:4000
networks:
- webnet
depends_on:
- db
db:
image: postgres:9.6
restart: always
environment:
- POSTGRES_USER=acronym
- POSTGRES_PASSWORD=acronym1234
- POSTGRES_DB=acronym
-PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- /var/lib/postgresql/data
ports:
- '5438:5432'
volumes:
db:
networks:
webnet:
I saw a lot of topic and the solution is to replace localhost to db but that doesn't work
How can i link my database to my app with docker-compose ?