Traefik and multiple separated services

I have main service on traefik.yml

version: "3.3"

services:
  traefik:
    image: "traefik:latest"
    container_name: "traefik"
    labels:
      - traefik.enable=${TRAEFIK_API_ENABLE:-false}
      - traefik.http.routers.api.rule=Host(`traefik.${TRAEFIK_DOMAIN}`)
      - traefik.http.routers.api.service=api@internal
      - traefik.http.routers.api.entrypoints=websecure
      - traefik.http.routers.api.tls.certresolver=letsencrypt
      - traefik.http.services.api.loadBalancer.server.port=8080 # dummy port required in host mode
    command:
      # act as a reverse proxy for docker containers with label "traefik.enable=true"
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --accessLog=true
      - --api.dashboard=${TRAEFIK_API_ENABLE:-false}
      - --entryPoints.web.address=:80
      - --entryPoints.websecure.address=:443
    env_file:
      - "./.env"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.rule=Host(`whoami.${TRAEFIK_DOMAIN}`)

And other service on other docker-compose file.

version: '3.8'

services:
    whoami:
        image: "traefik/whoami"
        container_name: "second-whoami"
        labels:
            - traefik.enable=true
            - traefik.http.routers.second-whoami.rule=Host(`second-whoami.${TRAEFIK_DOMAIN}`)

whoami works fine
second-whoami is visible on traefik, but when try to access, there is timeout. Host with other network is not accessible for traefik.

I know that I can use one network and then it works well, but I want to separate services.
Whoami and second-whoami should not see them-self.

Any idea?

Use Docker networks. Create one for each target service, have Traefik join both.

Check simple Traefik example.