I have a microservice developed with spring boot that connects with a mongodb. When a run it local, everything is ok. When I create a docker container to my microservice, but NOT to my mongodb, I receive an error of "connection refused". I was connecting to my mongodb at "localhost:27017", and then "127.0.0.1:27017", but both doesn't work. I know that the problem is this address because docker uses a network adapter different from the server, but I can't find how to configure to my spring boot container connects with my mongodb local. Is this approach wrong? I don't wanna to dockerize my mongodb because in the future the application will not be together with my database.
I'm using a Linux Ubuntu.