Variable interpolation question


Quite new to Nomad, and like it so far!

I have a question with regards to variable interpolation which I can’t really wrap my head around.

I’m trying to get docker containers spun up by Nomad to resolve towards local resolver running on host where container is placed (Unbound with stub-zone for consul DNS lookups for ~consul. domains, as well as forward-zones for upstream resolvers for everything else).

Trying to achieve this with something like below:

    network {
      mode = "bridge"

      port "http" {
        to = "xxxx"
      port "gossip" {
        to = "yyyy"
      dns {
        servers = ["${}"]

The network stanza lives in the “group” layer of the job atm. I’d imagine that the the above
"${}" would resolve to the host IP, but it actually never gets evaluated and /etc/resolv.conf will contain "${}" instead of resolved IP.

I’ve tried some different formats from Variable Interpolation | Nomad by HashiCorp, such as the {{ env “” }} but then run into syntax errors.

Would be awesome if someone could point to where I’m failing, if it’s syntax related or just not meant to be used like this.

Thanks for a great product!


1 Like

Hi @johanssone,

Have you been following this tutorial?

It says:

" For BIND, dnsmasq and Unbound, you will need to configure /etc/resolv.conf with a nameserver entry poining to localhost . This configures the operating system to forward the request to the chosen DNS daemon."

Have you tried that?