Hi, I'm not sure if traefik is the problem but I will try it here.
I have two docker containers from which I have to access the other via PHP script but this not working.
docker-compose.yml from traefik:
version: "3.5"
services:
traefik:
image: traefik:v2.8.5
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker.network=web"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- 80:80
- 8080:8080 #Management UI
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- web
networks:
web:
external: true
docker-compose.yml from A:
services:
php:
build: ./docker
container_name: "frontend-app"
labels:
- "traefik.enable=true"
- "traefik.docker.network=web"
- "traefik.http.routers.frontend.rule=Host(`frontend-app.docker.localhost`)"
ports:
- "8009:80"
volumes:
- ./docker/php/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# Source code
- ./apps/frontend:/var/www/html
networks:
project:
web:
aliases:
- "frontend.docker.localhost"
networks:
project:
driver: bridge
web:
external: true
docker-compose.yml from B:
services:
php:
build: ./docker
container_name: "backend-app"
labels:
- "traefik.enable=true"
- "traefik.docker.network=web"
- "traefik.http.routers.backend.rule=Host(`backend.docker.localhost`)"
ports:
- "8008:80"
volumes:
- ./docker/php/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# Source code
- ./apps/api:/var/www/html
networks:
project:
web:
aliases:
- "backend.docker.localhost"
networks:
project:
driver: bridge
web:
external: true
From my host system (mac) the urls of both container are reachable and work fine. But if I'm execute a call from php routing class in container A to the url (http://backend.docker.localhost/api/) results in a 404 from container A.
Is this a problem with traefik or have anyone hints where i can found the problem?
Thanks,
Stefan