Issue with docker labels having a . (dot)

Hi

I tried to set a docker label having dots as described for watchtower (Arguments - Watchtower) (also see Docker object labels | Docker Documentation)

  group "myapp" {

    task "myapp" {
      driver = "docker"
      config {
        image = "foo/bar"
        labels {
          com.centurylinklabs.watchtower.enable = "true"
        }
        ...

But nomad does not like it:

Error getting job struct: Error parsing job file from job.nomad:
job.nomad:52,11-14: 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.

Quoting is also not possible:

        labels {
          "com.centurylinklabs.watchtower.enable" = "true"
        }
Error getting job struct: Error parsing job file from job.nomad:
job.nomad:52,11-12: Invalid argument name; Argument names must not be quoted.

Any hints?

Hi @resmo and thanks for raising this issue.

I have done a little local testing and this seems to be related to a difference between the HCLv1 and HCLv2 job specification parser. Specifically, the example you posted works when submitting the job using the hcl flag such as nomad job run -hcl1 example.nomad.

The current behaviour with HCLv2 seems to require the labels configuration block to look like the following.

labels = {
  "com.centurylinklabs.watchtower.enable" = "true"
}

I am unsure currently whether this is a bug with the HCLv2 parsing, or whether our documentation needs to be updated to detail the differences. I have raised this GitHub issue to track this.

Thanks,
jrasell and the Nomad team

1 Like