my application.properties file
server.port=8085
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://init-postgres:5432/dbname
spring.datasource.username=username
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
and for dockerizing postgres I'm using command
docker run -d -p 5432:5432 --name init-postgres -e POSTGRES_DB=dbname -e POSTGRES_USER=username -e POSTGRES_PASSWORD=password postgres
but it gives java.net.UnknownHostException: init-postgres I'm beginner with Docker and learning it from a tutorial. to dockerized Postgresql & Spring boot app communication.
localhost... The container name will only work if you are also dockerizing your spring boot application and run them in the same network.localhost...