docker / cli

The Docker CLI
Apache License 2.0
4.91k stars 1.92k forks source link

Feature request: support templating in labels #4029

Open bluepuma77 opened 1 year ago

bluepuma77 commented 1 year ago

Description

Description

According to Docker service docs templates are only supported in 3 flags:

It would be great to have templates also supported in labels. This would enable for example individual host URLs per node when using Traefik as reverse proxy:

  whoami:
    image: traefik/whoami:v1.8
    networks:
      - proxy
    deploy:
      mode: global
      labels:
        - traefik.http.routers.whoami.rule=Host(`{{.Node.Hostname}}-whoami.example.com`)

A lot of configuration is based on labels these days, so this would really be helpful for Docker user.

Related issues that would make this feature request even more useful: Moby: Provide .Node.Labels in service templating SwarmKit: docker service create template support for Node labels

For reference, I originally opened issue #44981 with moby/moby

olljanat commented 1 year ago

Challenge in case of Traefik is that templating can only update container labels and Traefik in swarm mode is looking for service labels.