" To update the configuration of the Router automatically attached to the container, add labels starting with traefik.http.routers.<name-of-your-choice>. and followed by the option you want to change."
or
" To update the configuration of the Service automatically attached to the container, add labels starting with traefik.http.services.<name-of-your-choice>. , followed by the option you want to change."
I want to know, the is arbitrary and you can name whatever you want?
So for a service named foo, we can set the Label in docker compose file like:
traefik.http.services.bar.loadbalancer.server.port // although I set bar here, it is actually pointed to service foo?
It puzzles me a lot.
In fact, I don't think the docs was organized in a good understanding way (for a beginner). After a helpful example from Getting Started chapter, a very steep chapter comes with configuration which is really hard to understand is a big obstacle.
Or could you tell me how to use traefik well with some Prerequisites?
Traefik Services are not Swarm Services. <name-of-your-choice> is arbitrary.
Labels are key/value tuple. traefik.http.services.foo.xxx creates a Traefik Service named foo.
so for a container/swarm service:
services:
my-app:
# ...
deploy:
labels:
- "traefik.http.routers.foo.rule=Host(`example.com`)"
# - "traefik.http.services.bar.loadbalancer.server.port=<the port inside the container>"
- "traefik.http.services.bar.loadbalancer.server.port=1234
# ...
if you set bar here there is how your traefik service is named. So it is certainly not pointing to another traefic service named foo. As ldez explained traefik service is not the same as a swarm service.
It sounds like you've already read those above, but I would like to draw your attention to a couple of things you might have missed:
Traefik gets its dynamic configuration from providers: whether an orchestrator, a service registry, or a plain old configuration file.
The list of the providers can be found on the side bar under "Configuration Discovery", you will notice that Docker is just one provider of many.
On the other hand the concepts that was explained at the links above, e.g. routers and service, are traefik core concepts, they apply regardless of provider.
From this it follows, that swarm services and their name has nothing to do with traefik services and names, the latter will always be there in any traefik configuration, where the former may or may not be there depending on the provider you are using traefik with.
I hope this help a bit more in understanding this.