Docker container does not register right / not available if access too early

Currently I try to implement a setup with different docker environments. The setup includes a Traefik Proxy (docker-compose) and different environments (docker-compose setups too). My goal is, starting the proxy and add different docker environments on the fly. Now I have a strange behaviour:

I start the traevik proxy, then env 1 and the domains does also register. Means: When I call the address test.mydomain.de in my browser, I can access env 1. But when I start the proxy, call the address then and start then env 1, I can't reach the registered address test.mydomain.de in my browser. It does looks likes somehow it is cached, that the host wasn't available and traefik doesn't try it again to reach the host.

I would expext, that adding and remove on the fly is possible and traefik handles it right. Or is something wrong in my configuration?

Thats the scheme:

               +--------------------+
               |      Internet      |
               +--------------------+
                         |
               +--------------------+
               |   Traefik Proxy    |
               +--------------------+
                  |          |
+--------------------+     +--------------------+
|        Env 1       |     |        Env 2       |
+--------------------+     +--------------------+
           |                          |
          ...                        ...

Now, my setup for Traefik Proxy is the following docker-compose.yml:

version: '3.5'

services:
  traefik:
    restart: always
    image: traefik:2.2.1
    env_file:
      - .env
    ports:
      - '80:80'
      - '443:443'
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.api.rule=Host(`traefik.mydomain.de`)'
      - 'traefik.http.routers.api.entrypoints=https'
      - 'traefik.http.routers.api.service=api@internal'
      - 'traefik.http.routers.api.tls=true'
      - 'traefik.http.middlewares.api-basic-auth.basicauth.users=${API_AUTH}'
      - 'traefik.http.routers.api.middlewares=api-basic-auth'
    volumes:
      - ./certs:/certs
      - ./etc/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
      - ./etc/traefik/traefik-dynamic.yml:/etc/traefik/traefik-dynamic.yml:ro
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - 'web'
      - 'internal'

networks:
  web:
    external: true
  internal:
    name: internal

traefik.yml:

global:
  checkNewVersion: true

entryPoints:
  http:
    address: ':80'
    transport:
      lifeCycle:
        graceTimeOut: 10000000000
      respondingTimeouts:
        idleTimeout: 180000000000
    http:
      redirections:
        entryPoint:
          to: 'https'
          scheme: 'https'
          permanent: true
  https:
    address: ':443'

providers:
  providersThrottleDuration: 2000000000
  docker:
    watch: true
    endpoint: 'unix:///var/run/docker.sock'
    defaultRule: 'Host(`{{ normalize .Name }}`)'
    exposedByDefault: false
  file:
    filename: /etc/traefik/traefik-dynamic.yml

log:
  level: 'DEBUG'
  filePath: '/var/log/traefik.log'
  format: 'common'

api:
  dashboard: true

accessLog:
  filePath: '/var/log/access.log'

traefik-dynamic.yml:

tls:
  stores:
    default: {}
  certificates:
    - certFile: /certs/domain.crt.pem
      keyFile: /certs/domain.key.pem

Setup for env 1:

docker-compose.yml

version: '3.5'

services:
  node:
    image: nginx:alpine
    restart: 'always'
    volumes:
      - ./etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
      - ./srv/www:/srv/www
      - ./var/log/nginx:/var/log/nginx
    networks:
      - internal
      - web
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.node.rule=HostSNI(`test.mydomain.de`)'
      - 'traefik.http.routers.node.entrypoints=https'
      - 'traefik.http.routers.node.tls=true'

networks:
  web:
    external: true
  internal:
    external:
      name: internal

Welcome to the forum @prodigy7

You have multiple networks in both service. You need to configure traefik as to which network to use to reach the service. I think that is the only problem here.

You can set that on the traefik container or by the router on the backend container.

Sadly it doesnt change anything. Any idea how a "plugable" setup can be realized? In the past I used jwilder's docker-gen which works on that way, that I can plug and unplug containers everytime without any problem. The same goal I'd for traefik too.

Maybe that helps:

When the docker container in env 1 is started, that output is generated:

time="2020-07-02T13:10:54Z" level=debug msg="Provider event received {Status:start ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:start Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695454 TimeNano:1593695454396897000}" providerName=docker
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:10:54Z" level=debug msg="Provider event received {Status:start ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:start Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695454 TimeNano:1593695454396897000}" providerName=docker
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:10:54Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}},\"node\":{\"entryPoints\":[\"https\"],\"service\":\"node-node\",\"rule\":\"Host(`test.mydomain.de`)\",\"tls\":{}}},\"services\":{\"node-node\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://192.168.32.3:80\"}],\"passHostHeader\":true}},\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$iZlT3K6l$LvTaFZq2YWMwTEvK0j71O.\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

Stopping the container produce that output:

time="2020-07-02T13:12:43Z" level=debug msg="Provider event received {Status:die ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:die Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 exitCode:0 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695563 TimeNano:1593695563589745800}" providerName=docker
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:12:44Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}}},\"services\":{\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$iZlT3K6l$LvTaFZq2YWMwTEvK0j71O.\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

Maybe that output helps:

Starting container for env 1

time="2020-07-02T13:10:54Z" level=debug msg="Provider event received {Status:start ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:start Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695454 TimeNano:1593695454396897000}" providerName=docker
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:10:54Z" level=debug msg="Provider event received {Status:start ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:start Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695454 TimeNano:1593695454396897000}" providerName=docker
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:10:54Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:10:54Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}},\"node\":{\"entryPoints\":[\"https\"],\"service\":\"node-node\",\"rule\":\"Host(`test.mydomain.de`)\",\"tls\":{}}},\"services\":{\"node-node\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://192.168.32.3:80\"}],\"passHostHeader\":true}},\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$iZlT3K6l$LvTaFZq2YWMwTEvK0j71O.\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

Stopping the container for env 1

time="2020-07-02T13:12:43Z" level=debug msg="Provider event received {Status:die ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b From:nginx:alpine Type:container Action:die Actor:{ID:f651dbf316ae4cbcf1efea2f92b58d9529214b7d936f9818e305b3a9662e686b Attributes:map[com.docker.compose.config-hash:0a00012483870ec8c84487a4399280da71b3e896230486af88d9c59a99dfbc46 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod.yml com.docker.compose.project.working_dir:/var/www/production/test/docker/node com.docker.compose.service:node com.docker.compose.version:1.26.0 desktop.docker.io/binds/0/Source:/var/www/production/test/docker/node/srv/www desktop.docker.io/binds/0/Target:/srv/www desktop.docker.io/binds/1/Source:/var/www/production/test/docker/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/1/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Source:/var/www/production/test/docker/node/var/log/nginx desktop.docker.io/binds/2/Target:/var/log/nginx desktop.docker.io/wsl-distro:Ubuntu-20.04 exitCode:0 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.docker.network:web traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`test.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1593695563 TimeNano:1593695563589745800}" providerName=docker
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-backend-backend-fdae6c77d77d044c683f474c5716a5e95c9a0e64f134e7156a5f9c4ead36bd6e
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-database-backend-1f281bcddf5567d5f9d48676658d98f093e2f4fb4d25e267c439caf95016f5fa
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-redis-backend-f4686369bd870025159f510b2d7f1f89f3f358ea7f75c41c0b17d06812a98968
time="2020-07-02T13:12:44Z" level=debug msg="Filtering disabled container" providerName=docker container=test-management-management-c0479d8545165df776a066ee30474b9f920a6a3aa02b21e2c49b68b4aa369483
time="2020-07-02T13:12:44Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}}},\"services\":{\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$iZlT3K6l$LvTaFZq2YWMwTEvK0j71O.\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

I see your issue. You have HostSNI for your rule. That is a TCP router option.

You should be using a Host() rule.

You should have al least been getting a 404 back though.

Okay, I continued now, but still strange behaviours here. I simplyfied my setup (using only one network) a bit for finding the error.

traefik proxy
So, here is my traefik proxy docker-compose.yml:

version: '3.5'

services:
  traefik:
    restart: always
    image: traefik:2.2.5
    command:
      - '--api'
      - '--providers.docker=true'
      - '--providers.docker.exposedByDefault=false'
      - '--entrypoints.http=true'
      - '--entrypoints.http.address=:80'
      - '--entrypoints.http.http.redirections.entrypoint.to=https'
      - '--entrypoints.http.http.redirections.entrypoint.scheme=https'
      - '--entrypoints.https=true'
      - '--entrypoints.https.address=:443'
      - '--log=true'
      - '--log.level=DEBUG'
      - '--log.filepath=/var/log/traefik.log'
    env_file:
      - .env
    ports:
      - '80:80'
      - '443:443'
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.api.rule=Host(`traefik.mydomain.de`)'
      - 'traefik.http.routers.api.entrypoints=https'
      - 'traefik.http.routers.api.service=api@internal'
      - 'traefik.http.routers.api.tls=true'
      - 'traefik.http.routers.api.middlewares=api-basic-auth'
      - 'traefik.http.middlewares.api-basic-auth.basicauth.users=${API_AUTH}'
    volumes:
      - ./certs:/certs
      - ./etc/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
      - ./etc/traefik/traefik-dynamic.yml:/etc/traefik/traefik-dynamic.yml:ro
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - web

networks:
  web:
    name: web

The traefik.yml:

global:
  checkNewVersion: true

entryPoints:
  http:
    address: ':80'
    transport:
      lifeCycle:
        graceTimeOut: 10000000000
      respondingTimeouts:
        idleTimeout: 180000000000
    http:
      redirections:
        entryPoint:
          to: 'https'
          scheme: 'https'
          permanent: true
  https:
    address: ':443'

providers:
  providersThrottleDuration: 2000000000
  docker:
    watch: true
    endpoint: 'unix:///var/run/docker.sock'
    exposedByDefault: false
  file:
    filename: /etc/traefik/traefik-dynamic.yml

log:
  level: 'DEBUG'
  filePath: '/var/log/traefik.log'
  format: 'common'

api:
  dashboard: true

accessLog:
  filePath: '/var/log/access.log'

The traefik-dynamic.yml :

tls:
  stores:
    default: {}
  certificates:
    - certFile: /certs/domain.crt.pem
      keyFile: /certs/domain.key.pem

The .env contains only the var with the encrypted user/password.

env
The docker-compose.yml :

version: '3.5'

services:
  node:
    image: nginx:alpine
    restart: 'always'
    volumes:
      - ./etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
      - ./srv/www:/srv/www
      - ./var/log/nginx:/var/log/nginx
    networks:
      - web
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.node.rule=Host(`${DOCKER_HOSTNAME}`)'
      - 'traefik.http.routers.node.entrypoints=https'
      - 'traefik.http.routers.node.tls=true'

networks:
  web:
    external:
      name: web

The .env contains only the hostname used in the .yml.

Working
Now, the working setup is, when I start first the env and then the traefik proxy. The log file:

time="2020-07-14T12:17:45Z" level=info msg="Traefik version 2.2.5 built on 2020-07-13T16:35:29Z"
time="2020-07-14T12:17:45Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":-8446744073709551616},\"respondingTimeouts\":{\"idleTimeout\":-4467440737095516160}},\"forwardedHeaders\":{},\"http\":{\"redirections\":{\"entryPoint\":{\"to\":\"https\",\"https\":\"https\",\"permanent\":true,\"priority\":2147483647}}}},\"https\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"watch\":true,\"filename\":\"/etc/traefik/traefik-dynamic.yml\"}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"filePath\":\"/var/log/traefik.log\",\"format\":\"common\"},\"accessLog\":{\"filePath\":\"/var/log/access.log\",\"format\":\"common\",\"filters\":{},\"fields\":{\"defaultMode\":\"keep\",\"headers\":{\"defaultMode\":\"drop\"}}}}"
time="2020-07-14T12:17:45Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/contributing/data-collection/\n"
time="2020-07-14T12:17:45Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2020-07-14T12:17:45Z" level=debug msg="Start TCP Server" entryPointName=https
time="2020-07-14T12:17:45Z" level=debug msg="Start TCP Server" entryPointName=http
time="2020-07-14T12:17:45Z" level=info msg="Starting provider *file.Provider {\"watch\":true,\"filename\":\"/etc/traefik/traefik-dynamic.yml\"}"
time="2020-07-14T12:17:45Z" level=info msg="Starting provider *traefik.Provider {}"
time="2020-07-14T12:17:45Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
time="2020-07-14T12:17:45Z" level=debug msg="Configuration received from provider file: {\"http\":{},\"tcp\":{},\"udp\":{},\"tls\":{\"stores\":{\"default\":{}}}}" providerName=filetime="2020-07-14T12:17:45Z" level=debug msg="Configuration received from provider internal: {\"http\":{\"routers\":{\"http-to-https\":{\"entryPoints\":[\"http\"],\"middlewares\":[\"redirect-http-to-https\"],\"service\":\"noop@internal\",\"rule\":\"HostRegexp(`{host:.+}`)\",\"priority\":2147483647}},\"services\":{\"api\":{},\"dashboard\":{},\"noop\":{}},\"middlewares\":{\"redirect-http-to-https\":{\"redirectScheme\":{\"scheme\":\"https\",\"port\":\"443\",\"permanent\":true}}}},\"tcp\":{},\"tls\":{}}" providerName=internal
time="2020-07-14T12:17:45Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:17:45Z" level=debug msg="Provider connection established with docker 19.03.12 (API 1.40)" providerName=docker
time="2020-07-14T12:17:45Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}},\"node\":{\"entryPoints\":[\"https\"],\"service\":\"node-node\",\"rule\":\"Host(`mynode.mydomain.de`)\",\"tls\":{}}},\"services\":{\"node-node\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.28.0.3:80\"}],\"passHostHeader\":true}},\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.28.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:....\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker
time="2020-07-14T12:17:45Z" level=debug msg="No store is defined to add the certificate ....., it will be added to the default store." 
time="2020-07-14T12:17:45Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:17:45Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:17:46Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:17:46Z" level=debug msg="Added outgoing tracing middleware noop@internal" middlewareType=TracingForwarder routerName=http-to-https@internal entryPointName=http 
middlewareName=tracing
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" routerName=http-to-https@internal middlewareName=redirect-http-to-https@internal middlewareType=RedirectScheme entryPointName=http
time="2020-07-14T12:17:46Z" level=debug msg="Setting up redirection to https 443" routerName=http-to-https@internal middlewareName=redirect-http-to-https@internal middlewareType=RedirectScheme entryPointName=http
time="2020-07-14T12:17:46Z" level=debug msg="Adding tracing to middleware" entryPointName=http routerName=http-to-https@internal middlewareName=redirect-http-to-https@internal     
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" middlewareType=Recovery middlewareName=traefik-internal-recovery entryPointName=http
time="2020-07-14T12:17:46Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:17:46Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:17:46Z" level=debug msg="Added outgoing tracing middleware noop@internal" routerName=http-to-https@internal middlewareName=tracing middlewareType=TracingForwarder entryPointName=http
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" routerName=http-to-https@internal entryPointName=http middlewareName=redirect-http-to-https@internal middlewareType=RedirectScheme
time="2020-07-14T12:17:46Z" level=debug msg="Setting up redirection to https 443" routerName=http-to-https@internal entryPointName=http middlewareName=redirect-http-to-https@internal middlewareType=RedirectScheme
time="2020-07-14T12:17:46Z" level=debug msg="Adding tracing to middleware" entryPointName=http routerName=http-to-https@internal middlewareName=redirect-http-to-https@internal     
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining entryPointName=https routerName=node@docker serviceName=node-node
time="2020-07-14T12:17:46Z" level=debug msg="Creating load-balancer" entryPointName=https routerName=node@docker serviceName=node-node
time="2020-07-14T12:17:46Z" level=debug msg="Creating server 0 http://172.28.0.3:80" routerName=node@docker serviceName=node-node serverName=0 entryPointName=https
time="2020-07-14T12:17:46Z" level=debug msg="Added outgoing tracing middleware node-node" routerName=node@docker entryPointName=https middlewareName=tracing middlewareType=TracingForwarder
time="2020-07-14T12:17:46Z" level=debug msg="Added outgoing tracing middleware api@internal" routerName=api@docker middlewareName=tracing middlewareType=TracingForwarder entryPointName=https
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" middlewareType=BasicAuth entryPointName=https routerName=api@docker middlewareName=api-basic-auth@docker
time="2020-07-14T12:17:46Z" level=debug msg="Adding tracing to middleware" entryPointName=https middlewareName=api-basic-auth@docker routerName=api@docker
time="2020-07-14T12:17:46Z" level=debug msg="Creating middleware" middlewareType=Recovery entryPointName=https middlewareName=traefik-internal-recovery
time="2020-07-14T12:17:46Z" level=debug msg="Authentication succeeded" middlewareType=BasicAuth middlewareName=api-basic-auth@docker
time="2020-07-14T12:17:51Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:17:56Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:18:01Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth

Not working
The not working setup (got 404 page not found) is, when I start first the traefik proxy and then the env. The log file:

time="2020-07-14T12:21:19Z" level=info msg="Traefik version 2.2.5 built on 2020-07-13T16:35:29Z"
time="2020-07-14T12:21:19Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":-8446744073709551616},\"respondingTimeouts\":{\"idleTimeout\":-4467440737095516160}},\"forwardedHeaders\":{},\"http\":{\"redirections\":{\"entryPoint\":{\"to\":\"https\",\"https\":\"https\",\"permanent\":true,\"priority\":2147483647}}}},\"https\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"watch\":true,\"filename\":\"/etc/traefik/traefik-dynamic.yml\"}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"filePath\":\"/var/log/traefik.log\",\"format\":\"common\"},\"accessLog\":{\"filePath\":\"/var/log/access.log\",\"format\":\"common\",\"filters\":{},\"fields\":{\"defaultMode\":\"keep\",\"headers\":{\"defaultMode\":\"drop\"}}}}"
time="2020-07-14T12:21:19Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/contributing/data-collection/\n"
time="2020-07-14T12:21:19Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2020-07-14T12:21:19Z" level=debug msg="Start TCP Server" entryPointName=https
time="2020-07-14T12:21:19Z" level=info msg="Starting provider *file.Provider {\"watch\":true,\"filename\":\"/etc/traefik/traefik-dynamic.yml\"}"
time="2020-07-14T12:21:19Z" level=debug msg="Start TCP Server" entryPointName=http
time="2020-07-14T12:21:19Z" level=info msg="Starting provider *traefik.Provider {}"
time="2020-07-14T12:21:19Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
time="2020-07-14T12:21:19Z" level=debug msg="Configuration received from provider file: {\"http\":{},\"tcp\":{},\"udp\":{},\"tls\":{\"stores\":{\"default\":{}}}}" providerName=filetime="2020-07-14T12:21:19Z" level=debug msg="Configuration received from provider internal: {\"http\":{\"routers\":{\"http-to-https\":{\"entryPoints\":[\"http\"],\"middlewares\":[\"redirect-http-to-https\"],\"service\":\"noop@internal\",\"rule\":\"HostRegexp(`{host:.+}`)\",\"priority\":2147483647}},\"services\":{\"api\":{},\"dashboard\":{},\"noop\":{}},\"middlewares\":{\"redirect-http-to-https\":{\"redirectScheme\":{\"scheme\":\"https\",\"port\":\"443\",\"permanent\":true}}}},\"tcp\":{},\"tls\":{}}" providerName=internal
time="2020-07-14T12:21:19Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:21:19Z" level=debug msg="Provider connection established with docker 19.03.12 (API 1.40)" providerName=docker
time="2020-07-14T12:21:19Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}}},\"services\":{\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.29.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:...\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker
time="2020-07-14T12:21:19Z" level=debug msg="No store is defined to add the certificate ....., it will be added to the default store." 
time="2020-07-14T12:21:19Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:21:19Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:21:19Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:21:19Z" level=debug msg="Added outgoing tracing middleware noop@internal" entryPointName=http routerName=http-to-https@internal middlewareName=tracing middlewareType=TracingForwarder
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" entryPointName=http routerName=http-to-https@internal middlewareType=RedirectScheme middlewareName=redirect-http-to-https@internal
time="2020-07-14T12:21:19Z" level=debug msg="Setting up redirection to https 443" entryPointName=http routerName=http-to-https@internal middlewareType=RedirectScheme middlewareName=redirect-http-to-https@internal
time="2020-07-14T12:21:19Z" level=debug msg="Adding tracing to middleware" entryPointName=http routerName=http-to-https@internal middlewareName=redirect-http-to-https@internal     
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2020-07-14T12:21:19Z" level=debug msg="No default certificate, generating one" tlsStoreName=default
time="2020-07-14T12:21:19Z" level=debug msg="Adding certificate for domain(s) *.mydomain.de,mydomain.de"
time="2020-07-14T12:21:19Z" level=debug msg="Added outgoing tracing middleware noop@internal" entryPointName=http routerName=http-to-https@internal middlewareName=tracing middlewareType=TracingForwarder
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" middlewareType=RedirectScheme routerName=http-to-https@internal entryPointName=http middlewareName=redirect-http-to-https@internal
time="2020-07-14T12:21:19Z" level=debug msg="Setting up redirection to https 443" middlewareType=RedirectScheme routerName=http-to-https@internal entryPointName=http middlewareName=redirect-http-to-https@internal
time="2020-07-14T12:21:19Z" level=debug msg="Adding tracing to middleware" entryPointName=http middlewareName=redirect-http-to-https@internal routerName=http-to-https@internal     
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2020-07-14T12:21:19Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareType=TracingForwarder entryPointName=https routerName=api@docker middlewareName=tracing
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" entryPointName=https routerName=api@docker middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:19Z" level=debug msg="Adding tracing to middleware" entryPointName=https routerName=api@docker middlewareName=api-basic-auth@docker
time="2020-07-14T12:21:19Z" level=debug msg="Creating middleware" entryPointName=https middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2020-07-14T12:21:21Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:26Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:31Z" level=debug msg="Authentication succeeded" middlewareType=BasicAuth middlewareName=api-basic-auth@docker
time="2020-07-14T12:21:36Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:41Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:46Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:21:51Z" level=debug msg="Authentication succeeded" middlewareType=BasicAuth middlewareName=api-basic-auth@docker
time="2020-07-14T12:21:56Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:22:00Z" level=debug msg="Provider event received {Status:start ID:a039bc7f18fc083e11b1dce7d77947fc7deef33ae86d28e220f9652288f08111 From:nginx:alpine Type:container Action:start Actor:{ID:a039bc7f18fc083e11b1dce7d77947fc7deef33ae86d28e220f9652288f08111 Attributes:map[com.docker.compose.config-hash:adceee3277e013fbcf1af54acbd4189eb242214dc8bdde188f73fef0e2102386 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:node com.docker.compose.project.config_files:docker-compose.prod-cert.yml com.docker.compose.project.working_dir:/var/www/production/customer-myservice/docker/build/node com.docker.compose.service:node com.docker.compose.version:1.26.2 desktop.docker.io/binds/0/Source:/var/www/production/customer-myservice/docker/build/node/var/log/nginx desktop.docker.io/binds/0/Target:/var/log/nginx desktop.docker.io/binds/1/Source:/var/www/production/customer-myservice/docker/build/node/srv/www desktop.docker.io/binds/1/Target:/srv/www desktop.docker.io/binds/2/Source:/var/www/production/customer-myservice/docker/build/node/etc/nginx/conf.d/default.conf desktop.docker.io/binds/2/Target:/etc/nginx/conf.d/default.conf desktop.docker.io/wsl-distro:Ubuntu-20.04 image:nginx:alpine maintainer:NGINX Docker Maintainers <docker-maint@nginx.com> name:node_node_1 traefik.enable:true traefik.http.routers.node.entrypoints:https traefik.http.routers.node.rule:Host(`myservice.mydomain.de`) traefik.http.routers.node.tls:true]} Scope:local Time:1594729320 TimeNano:1594729320755122000}" providerName=docker
time="2020-07-14T12:22:00Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"https\"],\"middlewares\":[\"api-basic-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.mydomain.de`)\",\"tls\":{}},\"node\":{\"entryPoints\":[\"https\"],\"service\":\"node-node\",\"rule\":\"Host(`myservice.mydomain.de`)\",\"tls\":{}}},\"services\":{\"node-node\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.29.0.3:80\"}],\"passHostHeader\":true}},\"traefik-proxy\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.29.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"api-basic-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$iZlT3K6l$LvTaFZq2YWMwTEvK0j71O.\"]}}}},\"tcp\":{},\"udp\":{}}" providerName=docker
time="2020-07-14T12:22:01Z" level=debug msg="Authentication succeeded" middlewareName=api-basic-auth@docker middlewareType=BasicAuth
time="2020-07-14T12:22:06Z" level=debug msg="Authentication succeeded" middlewareType=BasicAuth middlewareName=api-basic-auth@docker

Any idea, whats wrong? For me, it actually has to be that I add services so that they work. It doesn't make sense that they have to be started before.

Were they different names in the runs on purpose and were they the names tested each time?

Pulled from the Configuration received from docker lines:
Env First Run. "rule": "Host(`mynode.mydomain.de`)",
Traefik First Run. "rule": "Host(`myservice.mydomain.de`)",

Sorry, just an error in anonymizing the configuration. The name in the original configuration is actually the same or correct at this point.

Update: Okay, I kept digging around to see if maybe it's a Docker problem.
I started the traefik proxy first, then the env environment. When I call up the domain in the browser, a "Page not found" appears. If I install w3m in the Proxy Docker container and then call the IP of the env container, the page I expect will appear.
This would indicate to me that something is fundamentally wrong when traefik registers the container. It does not look like a docker problem to me.

Hello, could you please look over The Static Configuration section in the docs? It seems that your configuration is not in line with the requirements outlined there.