Docker key labels with dot aren't supported in HCL 2.
Create a example.nomad and run nomad job plan example.nomad
job "example" {
datacenters = ["dc1"]
type = "service"
group "portal" {
count = 2
task "portal" {
driver = "docker"
config {
image = "nginx:alpine"
label {
traefik.enable = "true"
}
// labels = [
// "traefik.enable=true"
// ]
// label = {
// traefik.enable = "true"
// }
}
}
}
}
Error getting job struct: Failed to parse using HCL 2. Use the HCL 1 parser with `nomad run -hcl1`, or address the following issues:
example.nomad:14,11-18: Argument or block definition required; An argument or block definition is required here. To set an argument, use the equals sign "=" to introduce the argument value.
Create a example.nomad and run nomad job plan example.nomad. Now run nomad job run example.nomad and check the log events
job "example" {
datacenters = ["dc1"]
type = "service"
group "portal" {
count = 2
task "portal" {
driver = "docker"
config {
image = "nginx:alpine"
// label {
// traefik.enable = "true"
// }
labels = [
"traefik.enable=true"
]
// label = {
// traefik.enable = "true"
// }
}
}
}
}
2 errors occurred: * failed to parse config: * Incorrect attribute value type: Inappropriate value for attribute "labels": element 0: map of string required.

Create a example.nomad and run nomad job plan example.nomad. Now run nomad job run example.nomad. The container is started, but, as can seen in plan, no one label is applied.
job "example" {
datacenters = ["dc1"]
type = "service"
group "portal" {
count = 2
task "portal" {
driver = "docker"
config {
image = "nginx:alpine"
// label {
// traefik.enable = "true"
// }
// labels = [
// "traefik.enable=true"
// ]
label = {
traefik.enable = "true"
}
}
}
}
}
When I run docker inspect portal-<UUID>, traefik.enable isn't sent
"Labels": {
"com.hashicorp.nomad.alloc_id": "f90f7b86-4299-78f0-d5ef-fc5b3fdfd53f",
"maintainer": "NGINX Docker Maintainers <[email protected]>"
},
If you run nomad job plan -hcl1 example.nomad and nomad job run -hcl1 example.nomad, in the attempt 1 and attempt 3, they will works as expected.
Hi @SrMouraSilva . Sorry for the confusion there. Indeed, the syntax changed a little. We highlighted it in The HCL2 Backward Incompatibility section covers it a bit, and we'll aim to highlight it more.
As traefic.enable is not a valid identifier, the following block
label {
traefik.enable = "true"
}
needs to be re-writtern as:
label = {
"traefik.enable" = "true"
}
I've just tested the job with your job and it seems to have worked. Can you double check on your end too and report your finding.
Hi @notnoop. Thanks fot the answer. It works!
Most helpful comment
Hi @SrMouraSilva . Sorry for the confusion there. Indeed, the syntax changed a little. We highlighted it in The HCL2 Backward Incompatibility section covers it a bit, and we'll aim to highlight it more.
As
traefic.enableis not a valid identifier, the following blockneeds to be re-writtern as:
I've just tested the job with your job and it seems to have worked. Can you double check on your end too and report your finding.