Hi @scripthelp123 
No, that wouldn’t be possible without some extra coordination at the application level. In Nomad, each instance of a group (an allocation) looks the same since they are derived from the same jobspec file.
I think what you are looking for is a parameterized job. Here’s an example:
job "counter" {
datacenters = ["dc1"]
type = "batch"
parameterized {
meta_required = ["start"]
}
group "counter" {
task "counter" {
driver = "docker"
config {
image = "alpine:3.13"
command = "count.sh"
volumes = [
"local/count.sh:/usr/bin/count.sh",
]
}
template {
data = <<EOF
#!/bin/sh
count=${NOMAD_META_start}
while [ $count -lt 100000 ]
do
echo $count
count=$((count + 1))
done
EOF
destination = "local/count.sh"
perms = "777"
}
}
}
}
You can then register it:
$ nomad run counter.nomad
Job registration successful
And dispatch how many instances you need with different inputs:
$ nomad job dispatch -meta start=0 counter
Dispatched Job ID = counter/dispatch-1616598843-6b557dbb
Evaluation ID = 8f3a4dfd
==> Monitoring evaluation "8f3a4dfd"
Evaluation triggered by job "counter/dispatch-1616598843-6b557dbb"
Allocation "222d3e08" created: node "d710c448", group "counter"
==> Monitoring evaluation "8f3a4dfd"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "8f3a4dfd" finished with status "complete"
$ nomad job dispatch -meta start=1000 counter
Dispatched Job ID = counter/dispatch-1616598838-e761f7c3
Evaluation ID = f4356734
==> Monitoring evaluation "f4356734"
Evaluation triggered by job "counter/dispatch-1616598838-e761f7c3"
Allocation "10482406" created: node "d710c448", group "counter"
==> Monitoring evaluation "f4356734"
Evaluation status changed: "pending" -> "complete"
==> Evaluation "f4356734" finished with status "complete"