simas
1
Hi,
Traefik and other apps are started as Docker containers.
This all works fine for quite a while.
Now I tried to start a container using Docker Compose:
version: "3.3"
services:
vaadin-support:
container_name: vaadin-support
image: "dynasoftag/vaadin-support:latest"
restart: always
ports:
- "127.0.0.1:8765:8080"
networks:
- traefik
environment:
- TZ="Europe/Zurich"
- SUPPORT_FILE_PATH=/var/vaadin/support
labels:
- "traefik.docker.network=traefik"
- "traefik.http.routers.vaadin-support.tls=true"
- "traefik.port=8765"
volumes:
- /mnt/tosca5/Vaadin/Support:/var/vaadin/support
networks:
traefik:
external: true
But now Traefik does not recognize this container.
What's wrong with that? I also tried to move the labels to the deploy section but this also didn't work.
Any help is appreciated.
Simon
ldez
2
Hello,
Traefik works with Docker Compose.
You provided not enough information to be able to diagnose the problem.
The problem can be related to:
- the network
- the value of
docker.exposedByDefault
- the docker socket mount
- etc.
simas
3
That's how we start Traefik
docker run \
-d \
--restart always \
--network=traefik \
-l traefik.http.routers.dashboard.rule="Host(\`traefik.ds-docker01.ds.lan\`)" \
-l traefik.http.routers.dashboard.service=api@internal \
-l traefik.http.routers.dashboard.tls=true \
-l traefik.http.services.dashboard.loadbalancer.server.port=8080 \
-p 80:80 \
-p 443:443 \
-p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/ds/traefik.toml:/etc/traefik/traefik.toml \
-v /home/ds/ssl.toml:/etc/traefik/ssl.toml \
-v /home/ds/cert:/etc/traefik/cert \
--name traefik \
traefik:v2.3
The network is "traefik" and this is also used in the docker compose file. And the socket mount is also there.
docker.exposedByDefault is default (true)
First, you should probably use a current version of Traefik.
You have enabled the Traefik Dasboard, what does it say? You could also look into the Traefik debug log.
For your service, just check your labels, they do not seem correct.
This example service works for us:
whoami:
image: traefik/whoami:v1.8.1
networks:
- traefik
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.whoami.tls=true'
- 'traefik.http.routers.whoami.entrypoints=websecure'
- 'traefik.http.routers.whoami.rule=Host(`whoami.example.com`)'
- 'traefik.http.services.whoami.loadbalancer.server.port=80'
ldez
5
This is not a traefik v2 label.
Check you logs, I think you will see an error.
Offtopic: you are using a very old version v2.3, the latest version is v2.9
simas
6
Thanks a lot for your help!
I finally found the problem.
When starting with Docker compose, the URL becomes:
https://vaadin-support-vaadin-support.ds-docker01.ds.lan/
instead of:
https://vaadin-support.ds-docker01.ds.lan/
So it uses service_name-container_name with this configuration
defaultRule = "Host(`{{ normalize .Name }}.ds-docker01.ds.lan`)"`
How must the rule look like that Traefik only uses the container name?
simas
7
I finally found a solution in the forum:
defaultRule = "Host(`{{ coalesce (index .Labels \"com.docker.compose.service\") (normalize .Name) }}.ds-docker01.ds.lan`)"
system
Closed
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.