Answer the question
In order to leave comments, you need to log in
How to create a container for postgresq and spring boot applications? And that they interact with each other?
Good afternoon.
There is
FROM adoptopenjdk/openjdk11:x86_64-ubuntu-jre-11.0.13_8
ARG JAR_FILE=target/ShopWarehouse-0.0.1-SNAPSHOT.jar
WORKDIR /opt/app
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
version: "3.9"
services:
app:
build:
context: .
dockerfile: dockerfile
postgres:
image: "postgres:13.3-alpine"
environment:
- DB_DRIVER=org.postgresql.Driver
- DB_URL=jdbc:postgresql://postgres:5432/shop_warehouse
- POSTGRES_DB=shop_warehouse
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=12332112
ports:
- "5432:5432"
Answer the question
In order to leave comments, you need to log in
Good afternoon!
Firstly, when connecting jdbc, you need to specify the name of the service (postgres), instead
of localhost Secondly,
you need to add to yml
networks:
myApp:
name: myApp
driver: bridge
ports:
- "5432:5432"
networks:
- myApp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question