I am checking out traefik with docker-compose and I cannot figure out how to use the LB for internal-only compose containers when they are scaled up. Mind you: this is just a test, if this is completely wrong please tell me.
What I want: There are 3 different services, one reachable from the outside (api) and scaled to 3 instances (which works fine), the others only reachable internally, with a HTTP call from the api container to the docker-compose hostname (also works fine). Now if I scale up the internal ones, there is (obviously) no LB to handle the round robin for these, as they don't have any entrypoints, and the call will always go to the first one. However if I add entrypoints these would also be available from the outside. What am I missing here?
This is the compose file:
version: "3.7" services: traefik: image: "traefik:latest" command: - "--log.level=INFO" - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" ports: - "80:80" - "8080:8080" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro" depends_on: - api api: image: node:lts-alpine labels: - "traefik.enable=true" - "traefik.http.routers.api.rule=Host(`api.localhost`)" - "traefik.http.routers.api.entrypoints=web" - "traefik.http.middlewares.api.compress=true" working_dir: /app command: sh -c "npm i && npm run dev" env_file: ./.env depends_on: [jwt, auth] volumes: - ./api:/app - /app/node_modules expose: - 3000 # expose to traefik links: - auth - jwt scale: 3 jwt: image: node:lts-alpine working_dir: /app volumes: - ./jwt:/app - /app/node_modules command: sh -c "npm i && npm run dev" env_file: ./.env auth: image: node:lts-alpine working_dir: /app volumes: - ./auth:/app - /app/node_modules command: sh -c "npm i && npm run dev" env_file: ./.env