admin管理员组文章数量:1418637
I have a situation with Traefik here.
I wrote a docker-compose.yaml file that has a simple php application and an nginx container. My goal here is to deploy multiple versions of my composition using docker compose project feature. Problem is every two times, the request is forwarded to the wrong nginx.
Here is my compose.yaml file:
networks:
gateway:
external: true
application:
nginx:
image: nginx:latest
container_name: ${COMPOSE_PROJECT_NAME}_nginx
networks:
- application # <== This is the internal network
- gateway # <== This is the external network where traefik is deployed
expose:
- 80
labels:
- traefik.enable=true
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_home.rule=Host(`${COMPOSE_PROJECT_NAME}.${DOMAIN}`)
service:
#...
# here is my php application
Problem is when i do:
docker compose -p project_1 up -d
docker compose -p project_2 up -d
It works well for the first project. But when i try to reach project_2, it reaches the wrong nginx one time over two.
Do you have any idea why ?
My Traefik configuration is here:
global:
checkNewVersion: false
sendAnonymousUsage: false
log:
level: DEBUG
api:
dashboard: true
insecure: true
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
http:
tls: {}
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
watch: true
network: "gateway"
file:
filename: "/etc/traefik/tls.yaml"
watch: true
I have a situation with Traefik here.
I wrote a docker-compose.yaml file that has a simple php application and an nginx container. My goal here is to deploy multiple versions of my composition using docker compose project feature. Problem is every two times, the request is forwarded to the wrong nginx.
Here is my compose.yaml file:
networks:
gateway:
external: true
application:
nginx:
image: nginx:latest
container_name: ${COMPOSE_PROJECT_NAME}_nginx
networks:
- application # <== This is the internal network
- gateway # <== This is the external network where traefik is deployed
expose:
- 80
labels:
- traefik.enable=true
- traefik.http.routers.${COMPOSE_PROJECT_NAME}_home.rule=Host(`${COMPOSE_PROJECT_NAME}.${DOMAIN}`)
service:
#...
# here is my php application
Problem is when i do:
docker compose -p project_1 up -d
docker compose -p project_2 up -d
It works well for the first project. But when i try to reach project_2, it reaches the wrong nginx one time over two.
Do you have any idea why ?
My Traefik configuration is here:
global:
checkNewVersion: false
sendAnonymousUsage: false
log:
level: DEBUG
api:
dashboard: true
insecure: true
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
http:
tls: {}
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
watch: true
network: "gateway"
file:
filename: "/etc/traefik/tls.yaml"
watch: true
Share
Improve this question
asked Jan 29 at 14:23
Paul BHSPaul BHS
292 bronze badges
1
|
1 Answer
Reset to default 0You don't set a Traefik service name per container, so Traefik needs to create one, and it's probably using the container name. So you have two routers with different names, assigned to the same service name with two target containers.
Probably the simple solution: assign a unique Traefik service name, like in simple Traefik example:
whoami:
image: traefik/whoami:v1.10
networks:
- proxy
labels:
- traefik.enable=true
- traefik.http.routers.mywhoami.rule=Host(`whoami.example`)
- traefik.http.services.mywhoami.loadbalancer.server.port=80
Or use different names in compose file, not the same "nginx".
本文标签: nginxTraefik bad loadbalancing with docker compose projetcsStack Overflow
版权声明:本文标题:nginx - Traefik bad loadbalancing with docker compose projetcs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745292143a2651860.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
nginx
? Since they're on the same networks, I wouldn't be surprised if a Docker-internal DNS lookup returned both containers, and connections alternated between them. – David Maze Commented Jan 29 at 15:37