我正在使用带有领事作为后端的 traefik ,并且我需要使用 traefik 动态配置我的服务,在文档中,他们使用labels
config参数类似:
whoami:
image: containous/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
但这对我不起作用,而是使用environment
config参数,如下所示:
version: "3.7"
services:
consul:
image: consul
command: consul agent -server -dev -client=0.0.0.0 -ui -bootstrap -log-level warn
ports:
- "8400:8400"
- "8500:8500"
- "8600:53/udp"
registrator:
image: gliderlabs/registrator:latest
volumes:
- /var/run/docker.sock:/tmp/docker.sock
depends_on:
- consul
command: -internal consul://consul:8500
reverse-proxy:
image: traefik
command: --api --consulcatalog.endpoint=consul:8500
ports:
- 8080:8080
- 80:80
volumes:
- ./traefik.toml:/etc/traefik/traefik.toml
depends_on:
- registrator
inventory:
build:docker container in
context: ./inventory
expose:
- "5000"
environment:
- SERVICE_TAGS=traefik.enable=true,traefik.frontend.entryPoints=http,traefik.frontend.rule=Host:inventory.docker.localhost
使用标签时,traefik无法检测到配置,为什么会这样?
注意:如果您需要其他详细信息,请写评论。