I have a Docker Swarm cluster setup with 3 servers (1 manager and 2 employees).
I started the Postgresql service using the following command:
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 a data volume earlier:
docker volume create pg_data
Now I have another service that I want to run, basically this is a Java application that I put in 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: // local: 5432 / db
JDBC: PostgreSQL: // PostgreSQL: 5432 / db
Any idea what might work?
source
share