In my traefik.yml file, I can get constraints working as they used to in traefik v1 with this snippet:
providers:
docker:
constraints: "Label(`traefik.tags`, `branch-local`)"
I can see the behaviour I expect and anything without the branch-local tag is not handled by this traefik instance. I see debug output as I would expect, such as:
branch_proxy.1.gw5yrkatssko@docker-desktop | time="2020-03-14T10:58:17Z" level=debug msg="Container pruned by constraint expression: \"Label(`traefik.tags`, `branch-local`)\"" providerName=docker container=other-example-uuuvg811inqtdlyt1g0yvtm53
The constraints mechanism clearly works as it should, however, I can't use the yml file. I need to set the branch-something value dynamically from a build/deployment variable, not in my yml file, which is in a docker config; so, I need to do it in my docker-compose file.
If I add the following (similar to how we did in v1, and according to the new docs), it appears to be ignored):
services:
proxy:
image: traefik:cantal
command: --providers.docker.constraints="Label(`traefik.tags`,`branch-${NETWORK}`)"
If I go into the container and do a ps, I can see that the command is being correctly passed to the process command line:
PID USER TIME COMMAND
1 root 0:09 traefik traefik --providers.docker.constraints=Label(`traefik.tags`,`branch-local`)
28 root 0:00 /bin/sh
All of the running docker services, however, now go to this traefik instance, and we no longer see the filter messages in the log.