Open rllola opened 7 years ago
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 ghost-mysql
-repo as an example:
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. Who's up for a PR?
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 ?