Issues using custom docker templates

I've been trying to figure out how to use custom docker templates (as described here, but running into trouble when using the "stock" docker template for v1.7.14 ( Namely, when I try to start traefik with that template verbatim, I get this errror:

traefik_1  | time="2019-08-29T18:58:33Z" level=error msg="template: /etc/traefik/docker.tmpl:6: function \"getCircuitBreaker\" not defined"
traefik_1  | time="2019-08-29T18:58:33Z" level=debug msg="Received nil configuration from provider \"docker\", skipping."

Seems that the default template references some undefined function. Is there another base template I should be using, or an example of a traefik setup which provides a working docker template?



Try to add this in your configuration:

  templateVersion = 2
  # ...

# Override template version
# For advanced users :)
# Optional
# - "1": previous template version (must be used only with older custom templates, see "filename")
# - "2": current template version (must be used to force template version when "filename" is used)
# templateVersion = 2
1 Like

Thanks, that did it! FWIW I think the documentation could use a little clarification on this feature, since both version numbers claim they must be used and it's not clear which is the default value.

Separate question: do you know if Traefik 2 has a feature similar to templates which would allow for e.g. specifying default security headers?

Traefik v2 don't have any template.

The new design allow to do lot more thing than the v1 without using template.

The middleware can be define in a provider and applying on multiple routers.

1 Like