有没有办法traefik.http.services在 docker-compose 标签中设置名称?
可以说我有简单的 docker-compose.yml:
version: '3.4'
services:
traefik:
image: "traefik:v2.4.2"
command:
- --log.level=warning
- --api.insecure=true
- --api.dashboard=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
ports:
- "80:80"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
labels:
- traefik.enable=true
# Dashboard
- traefik.http.routers.traefik.rule=Host(`traefik.localhost`)
# this is interesting - traefik is naming his api service somehow
- traefik.http.routers.traefik.service=api@internal
- traefik.http.services.traefik.loadbalancer.server.port=8080
whoami:
image: "traefik/whoami"
labels:
- traefik.enable=true
- traefik.http.routers.webwho.rule=Host(`who.localhost`)
Run Code Online (Sandbox Code Playgroud)
当我可以在http://traefik.localhostdocker-compose up看到仪表板并在http://who.localhost看到“whoami”之后,这效果很好
问题是“whoami”traefik 服务的名称 -whoami-{name_of_project}当我想在其他标签中引用它时,这就是问题。
例如,我想使用新的 'foo' docker 服务作为 404.html 提供程序(在本例中我将使用 …