-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django can't translate "postgres" name for postrgres database #5
Comments
I don't know if you still need the answer to your problem. I feel a little sad that I hadn't written even a short notice because I actually would like to help people. But without investigating further I would not have had an answer to your question. But... I just came across the same problem and I found out why it happened. In short: You have to configure the networks correctly in your docker-compose-file. You can use the
If the network is only defined for the webserver, it will not be in the default-network for the compose-file anymore, but the database will still be. So the webserver will not know about the database. |
For future reference: When you specify the traefik network you're letting the container out of the default network, just add it to the networks too. Example: version: '3.1'
services:
cache:
restart: always
image: redis:latest
db:
restart: always
image: postgres:latest
backend:
restart: always
image: whatever:latest
links:
- cache
- db
networks:
- default # default network to be able to access cache and db
- traefik
labels:
- "traefik.port=80"
- "traefik.frontend.rule=Host:api.yggdrasil.dev"
- "traefik.docker.network=traefik_default" # telling traefik which network to use to reach the container
networks:
traefik:
external:
name: traefik_default |
"For future reference" sounds like this should be an example in the README.md. |
I usually use the name of my docker-compose service inside my django application to connect to the database (postgres) but when I use the reverse proxy on the Django service it says it can't translate 'postgres' to a hostname :
Usually docker-compose is able to do it.
Do you have any idea why it doesn't work when using the reverse-proxy and how I could fix it ?
The text was updated successfully, but these errors were encountered: