I created a microservice environment, more precisely 5 services, where they are connected to each other and access the same database (PostgreSQL). After development, I started to create the docker images for the services. All images have been created, however, I can not put postgreSQL in the docker environment, since it is already running on the machine in localhost, and other applications depend on it, so I can not migrate to the docker environment. I would like to know if it is possible for my applications to access the database that is outside the environment?
Below, my docker-compose
version: '2'
services:
server:
image: microservices/server:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
expose:
- "8080"
ports:
- "8080:8080"
networks:
- microservices
security-server:
image: microservices/security-server:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
expose:
- "8081"
ports:
- "8081:8081"
networks:
- microservices
restart: "always"
api-gateway:
image: microservices/api-gateway:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
expose:
- "9999"
ports:
- "9999:9999"
networks:
- microservices
restart: "always"
imovel:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "8082"
ports:
- "8082:8082"
networks:
- microservices
restart: "always"
imovel2:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9098"
ports:
- "9098:9098"
networks:
- microservices
restart: "always"
cliente:
image: microservices/cliente:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "8083"
ports:
- "8083:8083"
networks:
- microservices
restart: "always"
networks:
microservices:
driver: bridge
In the link quoted, his problem was that postgres wasn't accepting connections from outside. My problem is more of the beginning, where should I start configuring the connection?