Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Traefik container & whoami container on Docker Desktop but not able to get response from server

I would like to have Traefik & traefik/whoami containers up and running. Then access the whoami server via Traefik container.

I am using MacBook with M2 chip, that's armv8 architecture. So, the image I use for "whoami" server is traefik/whoami which support armv8.

I run them in my local Docker Desktop environment.

Here is my docker-compose.yml:

version: '3'

services:
  traefik:
    # The latest official supported Traefik docker image
    image: traefik:v2.3
    # Enables the Traefik Dashboard and tells Traefik to listen to docker
    # --providers tell Traefik to connect to the Docker provider
    # enable --log.level=INFO so we can see what Traefik is doing in the log files
    command: --api.insecure=true --providers.docker --log.level=INFO
    ports:
      # Exposes port 80 for incomming web requests
      - "80:80"
      # The Web UI port http://0.0.0.0:8080 (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events e.g. container starting
      - /var/run/docker.sock:/var/run/docker.sock

# Add the whoami service
  whoami:
     # A container that exposes an API to show its IP address
     image: traefik/whoami
     # We set a label to tell Traefik to assign a hostname to the new service
     labels:
       - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"

As you can see above, in the whoami service, I have set a Traefik host rule, that whoami.docker.localhost should point to "whoami" server.

I run docker-compose up -d, there is no problem. Both containers are up and running successfully. enter image description here

Then, I open browser (Chrome) to access the host, no server response: enter image description here

I also tried to access the Traefik dashboard http://localhost:8080, it is also can not be reached...

What am I missing?

like image 549
user842225 Avatar asked Nov 28 '25 19:11

user842225


1 Answers

I think you might be missing a few configuration options under "labels" in your whoami service - namely traefik.enable and traefik.http.routers.whoami.entrypoints=web.

Taken from https://hub.docker.com/r/traefik/whoami:

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
      - "traefik.http.routers.whoami.entrypoints=web"
like image 58
GChuf Avatar answered Nov 30 '25 08:11

GChuf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!