MADJDA ZERROUK
MADJDA ZERROUK

Reputation: 51

Can't access to Google Firestore Emulator docker image from my api container

I created a docker image for firebase emulators : auth, firestore, database and storage . I am running them in 0.0.0.0 My issue is that I am not able to access to them from my api docker container ( I can access to them from local api) The errors am having while trying to connect to emulators from my api docker image:

ERROR 14 UNAVAILABLE: No connection established

Upvotes: 2

Views: 853

Answers (1)

MADJDA ZERROUK
MADJDA ZERROUK

Reputation: 51

SOLUTION:

To connect to firebase container from another container we should put the HOST of the firebase emulator in the other container (api for example) as the name of the firebase service in the docker-compose file.

Example if the firebase part of my docker-compose is like that :

  firebase:
    container_name: firebase-emulators
    image:firebase-emulators
    ports:
      - '9099:9099' # Auth
      - '8080:8080' # Firestore
      - '9000:9000' # Database
      - '9199:9199' # Storage
      - '4000:4000' # UI

In my api code I should have :

process.env.FIREBASE_AUTH_EMULATOR_HOST=firebase:9099
process.env.FIRESTORE_EMULATOR_HOST=firebase:8080
process.env.FIREBASE_DATABASE_EMULATOR_HOST=firebase:9000
process.env.FIREBASE_STORAGE_EMULATOR_HOST= firebase:9199

Upvotes: 3

Related Questions