我只想使用Docker标签来提供Traefik服务,而不是路由器。
基本原理是将所有路由器保存在动态配置文件中,以便它们具有更易于理解的语法;因此,它们使我在配置中间件,路由规则和其他Traefik方面时都无需重新创建容器。
我设法使其与以下docker-compose一起使用:
services:
foobar:
...
expose:
- 8080
labels:
- traefik.enable=true
- traefik.http.services.foobar.loadbalancer.server.port=8080
# ^^^^^^ ^^^^
# this line configures both the service name and the backend port
和下面的Traefik yaml:
http:
routers:
foobar:
entryPoints: [web]
rule: Host(`foobar.mydomain.com`)
service: foobar@docker
# ^^^^^^
# this is the name defined above
这可行,但是Traefik还提供了一个名称为foobar-foobar@docker
和规则为Host("foobar-foobar")
的虚拟路由器
我想知道是否有办法避免虚设路由器。