can't able to connncet to mongodb when deploying web app for containers through docker-compose

BALIVADA Durga P 1 Reputation point
2020-11-06T10:53:00.22+00:00

Hi when m trying to deploy our code as a containers using docker-compose in web app for containers i can't able to connect to mongodb database throwig an error as mongoose disconneted

But when using the same docker-compose in my local machine i can able to connect to mongodb and able to deploy the app here is how my compose file looks like

version: "3.7"
services:
server:
image: "devops.azurecr.io/configuration_server"
environment:
- NODE_ENV=development
- MONGO_URL=mongodb://mongo:27017/configuration
- RUNNING_IN_DOCKER=true
depends_on:
- mongo
ports:
- "5000:5000"
client:
image: "devops.azurecr.io/configuration_client"
environment:
- NODE_ENV=development
- RUNNING_IN_DOCKER=true

ports:  
  - "3000:3000"  
depends_on:  
  - server                      

mongo:
image: "xaltdevops.azurecr.io/mongo"

hostname: mongodb

environment:  
  - MONGO_URL=mongodb://mongo:27017/onfiguration             
ports:  
  - 27017:27017  
volumes:  
  - mongodev:/data/mongoaz/  

please suggest me on this

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2020-11-30T19:06:35.517+00:00

    To benefit the community: Posting the solution that worked.

    There were 'Too Many redirects'- Application was redirecting infinitely. HTTPS redirection should not be handled at application level when running on Azure App Service. Azure App Service terminates all the HTTPS requests at Load Balancer level and further communication from Load Balancer to Instance is over HTTP (inside secure Azure Network ).

    We removed redirection from App level and Web app started successfully.

    Reference document: Process to bind custom domain to App Service and configure SSL certs.
    Custom Domain and SSL Cert

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Please do mark the post which was helpful by clicking on ‘Accept Answer’ & ‘Up-Vote’ to help the community find the right answers.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.