Here's my context: I have a caddy+php+mysql blog project with his docker-compose file, and I need to put a traefik reverse proxy in front. To test locally, I plan to serve this on blog.localhost to see what happens.
When I stack everything in the same docker-compose.yml, it works like a charm; But when I cut this in 2 different docker-compose.yml files, with the traefik in his own, I get some "Gateway Timeout".
I guess there is an issue of networks, that every containers into a single composition implicitely has a network between them, but between 2 files I need to declare one (first question : am I right ?)
But I tried to declare a network and nothing happened.
In fact, my issue can be reduced to this very case, the typical basic example from the traefik's official documentation:
version: "3.3"
services:
traefik:
image: "traefik:v2.3"
container_name: "traefik"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- "traefik.http.routers.whoami.entrypoints=web"
The question is how do you make this works in 2 separated docker-compose files / docker run commands ?
Thank you very much in advance !