Service/Router won't get created

Hey guys,

I have a problem with traefikv2 for some reason it does not want to work with caddy and I don't know why the heck that is. when I look into the dashboard it won't create a service or router for it, even though I use the same labels on that container as on any other container that works great. Here a little sneak peek into my docker-compose deployment:

version: '3'
services: 
    traefik:
        hostname: traefik
        image: library/traefik:2.2
        restart: always
        networks: 
            - default
            - vpn
        ports:
            - "80:80"
            - "443:443"
        env_file:
            - /data/Docker/env/traefik.env
        command:
            - "--providers.docker=true"
            - "--api.debug=true"
            - "--providers.docker.exposedByDefault=true"
            - "--api.dashboard=true"
            - "--providers.file.directory=/etc/traefik"
            - "--entrypoints.web.address=:80"
            - "--entrypoints.websecure.address=:443"
            - "--certificatesresolvers.dode=true"
            - "--certificatesresolvers.dode.acme.email=modzilla@mydomain.com"
            - "--certificatesresolvers.dode.acme.storage=/etc/traefik/acme.json"
            - "--certificatesresolvers.dode.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
            - "--certificatesresolvers.dode.acme.keytype=RSA4096"
            - "--certificatesresolvers.dode.acme.dnschallenge=true"
            - "--certificatesresolvers.dode.acme.dnschallenge.provider=dode"
        volumes: 
            - /data/Traefik/:/etc/traefik
            - /var/run/docker.sock:/var/run/docker.sock:rw
        labels:
            - "traefik.http.routers.api.rule=Host(`traefik.mydomain.com`)"
            - "traefik.http.routers.api.middlewares=redirect-to-https@docker"
            - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
            - "traefik.http.routers.api-secure.rule=Host(`traefik.mydomain.com`)"
            - "traefik.http.routers.api-secure.entrypoints=websecure"
            - "traefik.http.routers.api-secure.tls.certResolver=dode"
            - "traefik.http.routers.api-secure.tls=true"
            - "traefik.http.routers.api-secure.tls.domains[0].main=mydomain.com"
            - "traefik.http.routers.api-secure.tls.domains[0].sans=*.mydomain.com"
            - "traefik.http.routers.api-secure.service=api@internal"
            - "traefik.http.routers.api-secure.middlewares=auth"
            - "traefik.http.middlewares.auth.basicauth.users=modzilla:$$1$$$$/."

    caddy:
        image: caddy:2
        restart: always
        volumes:
            - /data/Docker/Caddyfile:/etc/caddy/Caddyfile:ro
            - /data/WebShare:/usr/share/caddy:ro
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.caddy-share.rule=Host(`share.mydomain.com`)"
            - "traefik.http.routers.caddy-share.entrypoints=web"
            - "traefik.http.routers.caddy-share.middlewares=redirect-to-https@docker"
            - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
            - "traefik.http.services.caddy-share.loadbalancer.server.port=80"
            - "traefik.http.routers.cadddy-share-secure.rule=Host(`share.mydomain.com`)"
            - "traefik.http.routers.caddy-share-secure.entrypoints=websecure"
            - "traefik.http.routers.caddy-share-secure.tls=true"
            - "traefik.http.services.caddy-share-secure.loadbalancer.server.port=80"

    jellyfin:
        image: jellyfin/jellyfin:latest
        restart: always
        volumes:
            - /data/Docker/jellyfin/config:/config
            - /data/Docker/jellyfin/cache:/cache
            - /data/Medien:/media
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.jellyfin.middlewares=redirect-to-https@docker"
            - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
            - "traefik.http.routers.jellyfin-secure.rule=Host(`jellyfin.mydomain.com`)"
            - "traefik.http.routers.jellyfin-secure.entrypoints=websecure"
            - "traefik.http.routers.jellyfin-secure.tls=true"
            - "traefik.http.services.jellyfin-secure.loadbalancer.server.port=8096"

EDITX: My logs shows the following:

traefik_1 | time="2020-07-04T19:46:01Z" level=error msg="Could not define the service name for the router: too many services" providerName=docker routerName=cadddy-share-secure
traefik_1 | time="2020-07-04T19:46:01Z" level=error msg="Could not define the service name for the router: too many services" providerName=docker routerName=caddy-share-secure
traefik_1 | time="2020-07-04T19:46:01Z" level=error msg="Could not define the service name for the router: too many services" providerName=docker routerName=caddy-share

Weird, is it a bug, because when searching my docker.compose file for caddd like the logs suggest I can't find anything?! I'm confused... The only way I can expose it right now is by using the auto-expose feature and setting thr Host to sth else or rather my domain and enabling tls to make the websecure endpoint usable.

Welcome to the forum @modzilla

The service is inheritly created with a docker service(when traefik.enable=true). You are defining what port to load balance, twice, with different names. So drop one of them and it should work.

1 Like

Oh okay, yeah that indeed fixed it, thanks!