From e83599dd0820fc4b7ef908b549d5bc0daaa117da Mon Sep 17 00:00:00 2001 From: Julien Maitrehenry Date: Thu, 4 Jan 2018 04:34:03 -0500 Subject: [PATCH] Add a note on how to add label to a docker compose file --- docs/configuration/backends/docker.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/configuration/backends/docker.md b/docs/configuration/backends/docker.md index bad8ad59d..47bed9af6 100644 --- a/docs/configuration/backends/docker.md +++ b/docs/configuration/backends/docker.md @@ -145,6 +145,20 @@ To enable constraints see [backend-specific constraints section](/configuration/ ## Labels: overriding default behaviour +!!! note + If you use a compose file, labels should be defined in the `deploy` part of your service. + + This behavior is only enabled for docker-compose version 3+ ([Compose file reference](https://docs.docker.com/compose/compose-file/#labels-1)). + +```yaml +version: "3" +services: + whoami: + deploy: + labels: + traefik.docker.network: traefik +``` + ### On Containers Labels can be used on containers to override default behaviour. @@ -224,11 +238,13 @@ Services labels can be used for overriding default behaviour !!! note - if a label is defined both as a `container label` and a `service label` (for example `traefik..port=PORT` and `traefik.port=PORT` ), the `service label` is used to defined the `` property (`port` in the example). + If a label is defined both as a `container label` and a `service label` (for example `traefik..port=PORT` and `traefik.port=PORT` ), the `service label` is used to defined the `` property (`port` in the example). + It's possible to mix `container labels` and `service labels`, in this case `container labels` are used as default value for missing `service labels` but no frontends are going to be created with the `container labels`. + More details in this [example](/user-guide/docker-and-lets-encrypt/#labels). !!! warning - when running inside a container, Træfik will need network access through: + When running inside a container, Træfik will need network access through: `docker network connect `