I have Java SpringBoot Web-application working on host machine. Application connects to PostgreSQL database. All works well. OS - Ubuntu 18.
Now i need to move application in Docker container, except for PostgreSQL which will remain on host machine.
I installed Docker, rise up container, but my app inside docker cannot connect to PostgreSQL database with default settings (localhost).
Here is my application.properties file:
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/webdemodb
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
spring.jpa.generate-ddl=true
Here is my Dockerfile:
FROM java:8
WORKDIR /
ADD target/webaccount-1.0-SNAPSHOT.jar app.jar
EXPOSE 8080
RUN fc-cache -f -v
ENTRYPOINT ["java","-jar","/app.jar"]
I read about Docker's networking but didn't find solution. What i need to setup?