Answer the question
In order to leave comments, you need to log in
How to fix hostname for postgres in docker-compose?
Hello. When I run the application, I get the error:
Error:springboot-postgresql | 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.
FROM openjdk:11
RUN mkdir -p /home/tst
WORKDIR /home/test
COPY . /home/test
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/home/test/hybridclient.jar"]
FROM postgres:12
EXPOSE 5432
version: '3.1'
services:
app:
container_name: springboot-postgresql
image: springboot-app
build: ./
ports:
- "9000:9000"
depends_on:
- postgresqldb
postgresqldb:
image: postgres
build:
context: ./
dockerfile: Dockerfile.postgres
ports:
- "5432:5432"
environment:
- PGDATA=/var/lib/postgresql/data
- POSTGRES_PASSWORD=111111
- POSTGRES_USER=usrdb
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question