Docker Community Forums

Share and learn in the Docker community.

Swarm: Task.Slot as runtime container label


(Zarnovican) #1


I’m trying to get the value of .Task.Slot into a container label (in Swarm).

This does not work (template variables are not expanded in label values):

    image: redis
      foo: "{{.Task.Slot}}"

There are existing labels, which contain that value (“3”) as a substring ( In my use-case, I’m not able to parse it out. I would like to have a label which contain just the task slot.

I’m monitoring containers via Telegraf. I would like to use Service.Name+Task.Slot as unique identifier for the series. If I use existing unique label (for example, Telegraf will create a new time-series every time someone makes a deploy.

It would be really ideal, if Swarm containers already had a label like that (com.docker.swarm.task.slot ?).

Any suggestions ?


(Junius) #2

You may try “-e TASK_SLOT={{.Task.Slot}}” when creating the service.