flask, neo4j and docker : Unable to retrieve routing information

Question:

I try to develop a mindmap API with flask and neo4j, i would like to dockerize all my project.
All services are started but backend dont want to communicate with noe4J …
I have this error :

neo4j.exceptions.ServiceUnavailable: Unable to retrieve routing information

Here is my code : https://github.com/lquastana/mindmaps

To reproduce the error just run a docker compose command and reach this endpoint : http://localhost:5000/mindmaps

Asked By: L. Quastana

||

Answers:

On my web service declaration I change NEO4J_URL from localhost to neo4j ( name of my service )

version: '3'
services:
  web:
    build: ./backend
    command: flask run --host=0.0.0.0 #gunicorn --bind 0.0.0.0:5000 mindmap_api:app
    ports:
      - 5000:5000
    environment: 
      - FLASK_APP=mindmap_api
      - FLASK_ENV=development
      - NEO4J_USERNAME=neo4j
      - NEO4J_PASSWORD=airline-mexico-archer-ecology-bahama-7381
      - NEO4J_URL=neo4j://neo4j:7687 # HERE
      - NEO4J_DATABASE=neo4j
    depends_on:
      - neo4j
    volumes:
      - ./backend:/usr/src/app

  neo4j:
    image: neo4j
    restart: unless-stopped
    ports:
      - 7474:7474
      - 7687:7687
    volumes:
      - ./neo4j/conf:/neo4j/conf
      - ./neo4j/data:/neo4j/data
      - ./neo4j/import:/neo4j/import
      - ./neo4j/logs:/neo4j/logs
      - ./neo4j/plugins:/neo4j/plugins
    environment: 
      # Raise memory limits
      - NEO4J_dbms_memory_pagecache_size=1G
      - NEO4J_dbms.memory.heap.initial_size=1G
      - NEO4J_dbms_memory_heap_max__size=1G
      - NEO4J_AUTH=neo4j/airline-mexico-archer-ecology-bahama-7381
Answered By: L. Quastana