Question about allocId in groups

I have a service that needs a stateful identity accessible from the running Docker container (use case: our chat bot needs to connect multiple times concurrently to Discord with a static instance index, that does not change when reconnecting).

It seems that I can create multiple instances of my service with a group by specifying count, and that will create a container and add the container index in the group to the name:

Nomad creates a container after pulling an image. Containers are named {taskName}-{allocId} . This is necessary in order to place more than one container from the same task on a host (e.g. with count > 1).

I have two questions about this:

  • is the allocId persistent? as in, if I update the jobspec according to rolling updates and the containers are recreated, does it keep the same allocId as the previous container?

  • is the allocId accessible from inside the container? I need this to get the index of the current instance, to provide to Discord while connecting.

Thank you!

figured it out by reading docs, I was looking for NOMAD_ALLOC_INDEX:sweat_smile:

Hi @spiralw; glad you figured it out. Please let me know if you have any followup questions.

jrasell and the Nomad team.