Traefik: Configuration with docker not working

I am trying to set up a sample application with the Traefik reverse proxy in Docker.

I am using Traefik v2.2 for this project which has significant differences from Traefik.v1.0.

Here is my docker-compose.yml file:

version: '3'

services:
  traefik:
    # The official v2 Traefik docker image
    image: traefik:v2.2
    # Enables the web UI and tells Traefik to listen to docker
    command:
      - --api.insecure=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --entrypoints.web.address=:80
    ports:
      # The HTTP port
      - "89:80"
      # The Web UI (enabled by --api.insecure=true)
      - "8089:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  whoami:
    # A container that exposes an API to show its IP address
    image: containous/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
      - "traefik.http.routers.whoami.entrypoints=web"

I can access Traefik's dashboard when I go to localhost:8089 on my web browser, but I cannot access the whoami application when I type in the whoami.localhost address on my web browser. I'm just wondering if there is anything I need to change before I can access it, or do I need to change the host from whoami.localhost to localhost:3000 since that's the port I want to access the application in.

Any form of help will be appreciated. Thank you.

You have exposed 89:80 so you want http://whoami.localhost:89

Wow. Thank you for this. It was very insightful

Modified the docker-compose.yml file to this:

version: "3"

services:
  traefik:
    # The official v2 Traefik docker image
    image: traefik:v2.2
    # Enables the web UI and tells Traefik to listen to docker
    command:
      - --api.insecure=true
      - --providers.docker=true
    ports:
      # The HTTP port
      - "89:80"
      # The Web UI (enabled by --api.insecure=true)
      - "8089:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
  whoami:
    # A container that exposes an API to show its IP address
    image: containous/whoami
    labels:
      - traefik.http.routers.whoami.rule=Host(`whoami.localhost`)

And then accessed it on my command terminal like this:

curl -H Host:whoami.localhost http://127.0.0.1:89

Thank you so much.