mirror of
https://github.com/containous/traefik.git
synced 2024-12-23 17:34:13 +03:00
Expose ContainerName in Docker provider
This commit is contained in:
parent
99d779a546
commit
4bc2305ed3
@ -440,10 +440,11 @@ _Optional, Default=```Host(`{{ normalize .Name }}`)```_
|
|||||||
|
|
||||||
The `defaultRule` option defines what routing rule to apply to a container if no rule is defined by a label.
|
The `defaultRule` option defines what routing rule to apply to a container if no rule is defined by a label.
|
||||||
|
|
||||||
It must be a valid [Go template](https://pkg.go.dev/text/template/), and can use
|
It must be a valid [Go template](https://pkg.go.dev/text/template/),
|
||||||
[sprig template functions](https://masterminds.github.io/sprig/).
|
and can use [sprig template functions](https://masterminds.github.io/sprig/).
|
||||||
The container service name can be accessed with the `Name` identifier,
|
The container name can be accessed with the `ContainerName` identifier.
|
||||||
and the template has access to all the labels defined on this container.
|
The service name can be accessed with the `Name` identifier.
|
||||||
|
The template has access to all the labels defined on this container with the `Labels` identifier.
|
||||||
|
|
||||||
```yaml tab="File (YAML)"
|
```yaml tab="File (YAML)"
|
||||||
providers:
|
providers:
|
||||||
|
@ -74,11 +74,13 @@ func (p *Provider) buildConfiguration(ctx context.Context, containersInspected [
|
|||||||
serviceName := getServiceName(container)
|
serviceName := getServiceName(container)
|
||||||
|
|
||||||
model := struct {
|
model := struct {
|
||||||
Name string
|
Name string
|
||||||
Labels map[string]string
|
ContainerName string
|
||||||
|
Labels map[string]string
|
||||||
}{
|
}{
|
||||||
Name: serviceName,
|
Name: serviceName,
|
||||||
Labels: container.Labels,
|
ContainerName: strings.TrimPrefix(container.Name, "/"),
|
||||||
|
Labels: container.Labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
provider.BuildRouterConfiguration(ctx, confFromLabel.HTTP, serviceName, p.defaultRuleTpl, model)
|
provider.BuildRouterConfiguration(ctx, confFromLabel.HTTP, serviceName, p.defaultRuleTpl, model)
|
||||||
|
Loading…
Reference in New Issue
Block a user