I have a Docker Swarm cluster setup with 3 servers(1 manager and 2 workers).
I started a Postgresql service using the command below:
docker service create --name postgresql \
--mount src=pg_data,dst=/var/lib/postgresql/data/pgdata \
-p 6542:5432 \
-e POSTGRES_USER="user" \
-e POSTGRES_DB="db" \
-e POSTGRES_PASSWORD="pass" \
-e PGDATA=/var/lib/postgresql/data/pgdata \
--constraint 'node.role == manager' \
postgres
I also created the data volume previously:
docker volume create pg_data
Now, I have another service that I want to start, which is basically a Java application that I bundled into a Docker image and I want to connect it to the postgresql service. I tried the following combinations for the url:
jdbc:postgresql://172.18.0.1:5432/db (docker_gwbridge)
jdbc:postgresql://172.17.0.1:5432/db (docker0)
jdbc:postgresql://localhost:5432/db
jdbc:postgresql://postgresql:5432/db
Any idea what could work?