Can not resole host when i use traefik

On my rasberry there runs a docker service.
I'm using portainer to manage my container. But i install everything by docker-compose.yml

Here is my file :

version: '3'

    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: always
      - "9000:9000"
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/pi/docker/volumes/portainer:/data:rw

    image: traefik:latest
    container_name: traefik
      - --api=true
      - --api.dashboard=true
      - --api.insecure=true
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --log=true
      - --log.level=INFO
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - "80:80"
      - "443:443"
      - "8080:8080"
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(`traefik.local`)"
      - "traefik.http.routers.api.service=api@internal"
      - "traefik.http.routers.api.entrypoints=web"
      - traefik
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/pi/docker/volumes/traefik/acme.json:/acme.json

    image: grafana/grafana
    container_name: grafana
      - "traefik.enable=true"
      - "traefik.http.routers.grafana.rule=Host(``)"
      - ""
      - "traefik.http.routers.grafana.entrypoints=web"
      - "traefik.port=3000"
      - /home/pi/docker/volumes/grafana:/var/lib/grafana:rw
    restart: always
    user: "${UID}:${GID}"
      - traefik

    external: true```

My Goal is to reach grafana service in this way :

But I got curl: (6) Could not resolve host:

You need to create a DNS entry that resolves the domain to the according IP.

When you just want that to work on only one machine, you can use a hosts file. When it should work in your whole home network, then you need to setup your (DSL?) router with the DNS.

Thank you for your fast response. Yes I want to use in my hole network
I'm using a fritz box. Do you know how to modify my router DNS

The hostname of my rasberry is rasberry-docker
Could a be a solution to config prefix in trafik so that i can call rasbery-docker/grafana

In FritzBox you can for sure set a local (sub-)domain name for a device.

Yes that is possible - but i have to config this for every service !?

Would i get the same result if i use a suffix like that - "traefik.http.routers.grafana.rule=Host(raspberry-docker) && Path(/grafana)"

Usually web-apps are not path-aware, but use a fixed path. You can use PathPrefix() and StripPrefix middleware for the request, but the web-app might respond with fixed paths in redirect and links (js, img), like /login and /script, which will not work.

It’s best practice to use sub-domains for web-apps. You can only use PathPrefix() with a web-app if it has some kind of „base path“ setting.

So new day new luck :wink:
I was thinking about your idea with sub domains.

Perhaps I have to say something about my setup or my goal :
I have a rapsberry pi where are many services : e.g grafana, pihole ....

Currently each container expose the nessarry ports. So I can reach my grafana Dashboard like this :

That works fine. But I want to reach it this way : (for example)

But My Browser send the request to the router but it coukd find a DNS response for this URL.
So my question is : When i configure my with Rebimd DNS protection , I have to add each URL like this

But why should this work.