title: Want to connect mongodb docker service with my django application
body: <p><a href="https://i.stack.imgur.com/gWpZ1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWpZ1.png" alt="while running docker-compose up getting this error. "></a>I want to create <strong>two docker services</strong> one is mongodb service another one is web service build using django. And i need that web-service (django app) which need to be connected to that mongodb docker service.</p>
  
  <p>but i dont know how to <strong>connect with mongodb docker service in my django</strong> application which is also a service running in a same docker swarm .`This is <strong>my docker-compose.yml</strong>:</p>
  
  <pre><code>version: '3'
  
  services:
    mongo:
      image: mongo:latest
      command: mongod --storageEngine wiredTiger
      ports:
        - "27017:27017"
      restart: always
      environment:
        MONGO_INITDB_ROOT_USERNAME: root
        MONGO_INITDB_ROOT_PASSWORD: example
    web:
      build: .
      command: python3 manage.py runserver 0.0.0.0:8000
      volumes:
        - .:/code
      ports:
        - "8000:8000"
      links:
        - mongo
      depends_on:
        - mongo
  </code></pre>
  
  <p>Here i tried with mongoengine in <strong>settings.py</strong> of django application but failed</p>
  
  <pre><code>MONGO_DATABASE_NAME = "reg_task21"
  MONGO_HOST = "mongo"
  
  mongoengine.connect(db=MONGO_DATABASE_NAME, host=MONGO_HOST,port=27017)
  </code></pre>