In these days, I am trying to deploy my Spring Boot OAuth2 project. It has 3 different modules.(Authentication Server, Resource Server and Front-end) Authentication and Resource servers have own *.yml file for configurations such as mongodb name-port, server profile-ip etc. What I am trying to do exactly? I want to deploy spring boot application on docker but i dont want to put my database(mongodb) on docker as a container. I am not sure this structure is possible or not ? Because When i run my mongodb on my local(localhost:27017) after that try to deploy spring boot application on local docker as a container, i am getting Timeout exception for MongoDB. The application couldnt connect to external mongoDB(non docker container).
What should I do? Should I run mongodb on docker? I tried it also, Mongo runs successfully but still spring container couldnt run and connect to mongo. I tried to run another spring boot app without mongodb, it is working successfully and i made request from browser by ip&port, i got response from application as i expected.
*** MONGO URL **** mongodb://127.0.0.1:27017/db-localhost **** Authentication server .yml file **** server: port: 9080 contextPath: /auth-service tomcat: access_log_enabled: true basedir: target/tomcat security: basic: enabled: false spring: profiles: active: development thymeleaf: cache: false mongo: db: server: 127.0.0.1 port: 27017 logging: level: org.springframework.security: DEBUG --- spring: profiles: development data: mongodb: database: db-localhost --- spring: profiles: production data: mongodb: database: db-prod --- ***** DOCKER FILE ******* FROM java:8 VOLUME /tmp ADD auth-server-1.0-SNAPSHOT.jar app.jar EXPOSE 9080 RUN bash -c 'touch /app.jar' ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] **** DOCKER COMMAND ******* docker run -it -P --name authserver authserver