How to connect to DB? What is hostname of another running template? #2425
Answered
by
djsisson
Serhioromano
asked this question in
Q&A
-
|
I have Logto template running. It have 2 containers, app and postgres. I created another service pgAdmin. It works fine. Now I want to connect to postgres of logto service. This is my pgAdmin service services:
pgadmin:
image: dpage/pgadmin4:2025-08-20-1
restart: unless-stopped
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
- PGADMIN_CONFIG_SERVER_MODE=False
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
volumes:
- pgadmin-data:/var/lib/pgadmin
networks:
dokploy-network:
external: true
volumes:
pgadmin-data:But whatever I enter in hostname when connect new DB fails with cannot resolve. What is hostname of postgres service that I can access in another service? My logto service looks like this services:
app:
depends_on:
postgres:
condition: service_healthy
image: ghcr.io/logto-io/logto:1.27.0
entrypoint: ["sh", "-c", "npm run cli db seed -- --swe && npm start"]
ports:
- 3001
- 3002
environment:
TRUST_PROXY_HEADER: 1
DB_URL: postgres://logto:${LOGTO_POSTGRES_PASSWORD}@postgres:5432/logto
ENDPOINT: ${LOGTO_ENDPOINT}
ADMIN_ENDPOINT: ${LOGTO_ADMIN_ENDPOINT}
volumes:
- logto-connectors:/etc/logto/packages/core/connectors
postgres:
image: postgres:17-alpine
user: postgres
environment:
POSTGRES_USER: logto
POSTGRES_PASSWORD: ${LOGTO_POSTGRES_PASSWORD}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "logto"]
interval: 10s
timeout: 5s
retries: 5
networks:
dokploy-network:
external: true
volumes:
logto-connectors:
postgres-data: |
Beta Was this translation helpful? Give feedback.
Answered by
djsisson
Aug 20, 2025
Replies: 1 comment 1 reply
-
|
they need to be in the same docker network in order to connect using a service name |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Serhioromano
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
they need to be in the same docker network in order to connect using a service name