docker / docker/cli

Feature request: support templating in labels

Open
#4,029 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/swarm kind/feature status/0-triage
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description
Description

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

  • hostname
  • mount
  • env

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Docker service templating documentation and compare the existing hostname, mount, and env template support with how service labels are handled. Use the Traefik example as the acceptance case: label values should support expressions such as {{.Node.Hostname}} when creating a service.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.