Description of configs templates? Way to substitude IP for host?

Swarm has this concept of configs, with its templating system to substitute values in confgs. Something that would fit very well with docker-compose btw.

Anyway, where can I get a description of the possible variables I can substitute via templates?

Specifically, I’d like to insert the IP of hosts in the same (overlay) network. For example to configure the primary bind9 in the secondaries you can only use literal IP, it doesn’t do any hostname lookups. But Docker/Swarm assigns dynamic IPs, so I’d like to insert the dynamic IP of the primary.

This github issue seems to be the most complete description:

This seems to be the full example that shows how all different data sources are used:

docker config create --template-driver=golang example -<<'EOF'
This template is used on service: {{.Service.Name}}
This container is running on node with ID: {{.Node.ID}}
HELLO environment variable is: {{env "HELLO"}}
Secret "secret1" contains: {{secret "secret1"}}
Some other config ("config1") contains: {{config "config1"}}
EOF

Looks like you are limited to swarm template placehoders, terminal environment variables, swarm secrets, and swarm configs.

This blog post seems to cover it in depth as well:

Though, I am not sure how template configs would help in this particular use case, where you need dynamic ip resolution for other containers.

Looks like you will have to do it the good old way: pass in an environment variable with the service name you want to resolve, then create an entrypoint script that resolves the ip of the service name, and then modifies the config file before the main process is started.