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"
imovel3:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9097"
ports:
- "9097:9097"
networks:
- microservices
restart: "always"
imovel3:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9096"
ports:
- "9096:9096"
networks:
- microservices
restart: "always"
imovel4:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9095"
ports:
- "9095:9095"
networks:
- microservices
restart: "always"
imovel5:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9094"
ports:
- "9094:9094"
networks:
- microservices
restart: "always"
imovel6:
image: microservices/imovel:latest
mem_limit: 1073741824 # RAM 1GB
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- server
- security-server
- api-gateway
expose:
- "9093"
ports:
- "9093:9093"
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
Someone?