-1

I have simple express js app, postgres db and graphql engine with docker-compose file like this:

version: '3.9'

services:
  server:
    build: .
    ports:
      - '5000:5000'

  db:
    image: 'postgres'
    # ports:
    #   - '4321:5432'
    environment:
      POSTGRES_PASSWORD: '123'
      POSTGRES_USER: 'docker'
    volumes:
      - data:/var/lib/postgresql/data



  graphql-engine:
    image: hasura/graphql-engine:v1.0.0-beta.6
    ports:
    - "8080:8080"
    depends_on:
    - "db"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://docker:123@172.25.0.3:5432/docker   # postgres://username:password@hostname:port/dbname 
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
      ## uncomment next line to set an admin secret
      # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey

volumes:
  data: 
    

When I run: docker-compose up --build -d, then express js app is running, (I can access it at http://localhost:5000), postgres also runs, but not sure how to access graphql-hasura interface. It wont works at: http://localhost:8080/

What I'm missing ?

Oto Shavadze
  • 40,603
  • 55
  • 152
  • 236

1 Answers1

1

looking at your docker-compose.yml and checking the database connection string, you are referring to the IP. In docker you should always try to focus on "dns/alias" instead of IP, since IP will probably be different each time you run it (unless you define a static ipv4 address in the network spec part of the compose).

You should try to adjust: HASURA_GRAPHQL_DATABASE_URL: postgres://docker:123@172.25.0.3:5432/docker # postgres://username:password@hostname:port/dbname - to use the "db" alias instead of "172.25.0.3" IP.

matic1123
  • 914
  • 6
  • 15