Traefik fails to do port detection on Docker network with internal flag

This is the error line:

time="2021-07-16T12:55:53Z" level=error msg="service \"whoami-traefik\" error: port is missing" container=whoami-traefik-cbc6784c0c1452147348cf636a3ed5ec85f96370562d8fb4e94b5c3c01f18b05 providerName=docker

This is my config file traefik.yml:

api:
  insecure: true
  dashboard: true

entryPoints:
  web:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https

  websecure:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
    network: traefikproxy

certificatesResolvers:
  domain:
    acme:
      email: <redacted>
      storage: acme/acme-domain.json
      dnsChallenge:
        provider: <redacted>
        resolvers:
          - "1.1.1.1:53"
          - "8.8.8.8:53"

This is my compose file docker-compose.yml:

version: "3.8"

services:
  traefik:
    image: traefik:v2.4
    container_name: traefik
    command:
     - --log.level=DEBUG
    networks:
      - default
      - traefikproxy
    environment:
      - <redacted>
    ports:
      - 80:80
      - 443:443
      - 48080:8080
    volumes:
      - /opt/traefik/config/traefik.yml:/traefik.yml:ro
      - /opt/traefik/config/acme:/acme
      - /var/run/docker.sock:/var/run/docker.sock:ro

  whoami:
    image: traefik/whoami
    container_name: simple-service
    networks:
      - traefikproxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.rule=Host(`whoami.domain`)
      - traefik.http.routers.whoami.entrypoints=websecure
      - traefik.http.routers.whoami.tls=true
      - traefik.http.routers.whoami.tls.certresolver=domain
      - traefik.docker.network=traefikproxy

networks:
  default:
  traefikproxy:
    external: true

I have my traefik instance setup with two networks in Docker compose, one named default for certificate creation and other things requiring internet access (outbound traffic) and one named traefikproxy (created with docker network create -d bridge --internal --attachable traefikproxy) only for communicating between other container and traefik (no outbound) so no other container use it for outbound connection. I've set the default network in traefik to traefikproxy in my traefik.yml, even tried overriding it in the container proxied. It seems that it only occurs when I set the internal flag when creating the traefikproxy network, because when I add the default network or recreate the network without internal flag, it works again. I am in the process of learning traefik and moving from caddy-docker-proxy, so please point me in the right direction. Thank you.

Hello @ChrisG661,

There is a section on docker port detection in the documentation: (Docker - Traefik).

Since your whoami service does not expose any ports, you need to tell Traefik what port to use.

traefik.http.services.whoami.loadbalancer.server.port=80