I am using docker-compose to create applications and mongodb containers .

The below line of code creates a mongoDB container and I am referring the service name “mongodb-service” in application containers to connect to mongoDB .

I am doing A POC , where I need to connect to mongoDB atlas not to mongoDB container.
How I can connect to mongoDB atlas as a service , how to define HOST URL and user name password in that service .

  mongodb:
    image: mongo:latest
    ports:
      - 27017:27017
    networks:
      mynetwork:
        aliases:
          - mongodb-service
    volumes:
      - vol-mongo-db:/mongo/db
      - vol-mongo-configdb:/mongo/configdb

Hi @shirish_sahu and welcome to the community!!

As I understand the above statement correctly, the application is also using docker and is deployed using docker compose.
Can you please help with the connection string that the application is using currently to connect the application with the database?
If the URI is pointing towards mongodb-service, you can change the current URI with the Atlas URI instead.

Please let us know if you have any further questions.

Thanks
Aasawari

1 Like

Hello Aasawari,
I have a timeout problem, when starting my application the connection is well established and the collections are created. But when I make an HTTPS request to my container which hosts my nodejs application, the request arrives well in my application but I have the impression that it is at the level of the container and Atlas connection