posgrest not connecting to DB if we use docker-compose.yml #2252
-
Environment
Description of issue(Expected behavior vs actual behavior) (Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Error details: db is Service Name of postgres Database in docker-compose file |
Beta Was this translation helpful? Give feedback.
-
Can you share the |
Beta Was this translation helpful? Give feedback.
-
As Steve mentioned, the An answer I found to a similar error is to add both to a network, maybe it helps. Something like: # docker-compose.yml
version: '3'
services:
server:
image: postgrest/postgrest
ports:
- "3000:3000"
environment:
PGRST_DB_URI: postgres://app_user:password@db:5432/app_db
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: app_user #In production this role should not be the same as the one used for the connection
PGRST_OPENAPI_SERVER_PROXY_URI: http://127.0.0.1:3000
depends_on:
- db
links:
- db:db
networks:
- pgnetwork
db:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_DB: app_db
POSTGRES_USER: app_user
POSTGRES_PASSWORD: password
networks:
- pgnetwork
# Uncomment this if you want to persist the data.
# volumes:
# - "./pgdata:/var/lib/postgresql/data"
networks:
pgnetwork:
driver: bridge
|
Beta Was this translation helpful? Give feedback.
Can you share the
docker-compose
file?