cancel
Showing results for 
Search instead for 
Did you mean: 

Docker image with mongo accesible from outside

0 Kudos

Hello,

Im new on Cloud Foundry and SAP so Im very lost.

I push a docker image with MongoDB to CF SAP. I can connect by cf ssh and access to the database.

Now, Im trying to connect from MongoDB Compass but I dont know if its possible or how.

I configure CFAR to add port 27017 and update route mapping but I dont know what else I should do.

https://docs.cloudfoundry.org/devguide/custom-ports.html

Im trying to connect from MongoDB compass with hostname (SAP cloud Application Route) and Port 27017 but without any sucess.

Could someone give me some guidance on how to do it?

Regards

Accepted Solutions (0)

Answers (2)

Answers (2)

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

Please be aware that CF apps don't come with persistence. If you are planning to run a docker image in CF, you will lose all your data once the app will be restarted/restaged.

If you want to run a mongo DB, I recommend using a backing service. These services provide persistence out of the box.

0 Kudos

Hi, can you give me some documentation about this? I have read some tutorials about this, but unfortunately MongoDB has been removed from service marketplace.

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

You are right, SAP is currently not offering a MongoDB service to new customers/to trial users. There are, however, other options to connect the Cloud Foundry Application Runtime (CFAR) to a MongoDB:

1. You provision the MongoDB in a data center of our hyperscaler partners such as AWS, Azure, GCP. Here's a tutorial group that does the necessary setup for Azure (you only need to follow the first three tutorials).

2. You can provision the MongoDB from any Cloud vendor and inject it into Cloud Foundry as a user-provided service instance.

The advantage of the second approach is its simplicity but here you will have to manage the lifecycle of your MongoDB by yourself.

0 Kudos

Ok, I think I'm going to try option 2, thank you very much for the help.

Anyway, it is not possible to expose port 27017 to connect from MongoDB Compass? Apparently I have exposed port 27017 of my application but I am not able to connect. Should I do something else or is it not possible?

gregorw
Active Contributor
0 Kudos

Have you checked this documentation? Which describes that you have to use the EXPOSE directive?

0 Kudos

Yes, I Expose the 27017 port in the docker image file and configure 27017 port in CFAR as I read in te documentation.

If I execute "cf curl /v2/route_mappings" I can see that the app_port: 27017 is configured, but I cant connect by MongoDB Compass.