【发布时间】:2019-10-16 10:24:44
【问题描述】:
所以,我正在尝试使用 Traefik 通过 docker swarm 对我的 Web 应用程序进行负载平衡。
但是,我已经尝试了许多配置,但不知何故不起作用。我已经阅读了文档并阅读了互联网上的一些文章。不幸的是,许多文章引用 traefik 1.x 而不是 traefik 2.0。
这是我用于 traefik 的 docker-stack.yml
version: '3.7'
services:
traefik:
image: traefik:2.0
deploy:
mode: global
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
labels:
- traefik.docker.network=load_balancer
configs:
- source: traefik
target: /etc/traefik/traefik.yml
ports:
- 80:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- load_balancer
configs:
traefik:
file: ./traefik.yml
networks:
load_balancer:
external: true
name: load_balancer
whoami.yml(用于测试目的)
version: '3.7'
services:
whoami:
image: containous/whoami
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=load_balancer
- traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)
networks:
- load_balancer
networks:
load_balancer:
external: true
name: load_balancer
我的 traefik.yml
log:
level: DEBUG
api:
insecure: true
providers:
docker:
exposedByDefault: false
swarmMode: true
watch: true
docker 网络 ls
hxjw9rytw3od load_balancer overlay swarm
curl -H 主机:whoami.docker.localhost http://127.0.0.1
404 page not found
【问题讨论】:
标签: docker-swarm traefik