I have this YAML file
version: '2'
services:
app:
image: 'docker-spring-boot-postgres:latest'
ports:
- "8085:8085"
build:
context: C:\Users\Grigor_Martirosyan\IdeaProjects\docker\src\main\docker\Dockerfile
container_name: app
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/testdb
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=admin
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=admin
the app says connection error
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres"
I tried to change connection details but still gives that error, it just changed, before it gave like TCP/IP error .but now that error.
Now it gives this error
Caused by: 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.
$SPRING_DATASOURCE_URL, use the Compose service namedbas the host name part of the URL. In Dockerlocalhostusually means "the current container", not another container or the containing host. Also see Networking in Compose in the Docker documentation.localhostis a differentlocalhostfrom the application container'slocalhostor your host system'slocalhost.