I don't get how I should set up the routes to my containers. In my local home network I have a raspberry pi that runs ubuntu and docker (raspy.local
is the host name of the raspberry pi). I want my containers to be accessible via http://raspy.local/<servicename>
.
Here is my docker-compose.yml for traefik and whoami:
version: '3'
networks:
home_network:
name: home_network
services:
traefik:
container_name: traefik
image: traefik:v2.4
command:
- --api.insecure=true
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --global.checknewversion=true
- --global.sendanonymoususage=false
- --api.dashboard=true
- --entryPoints.web.address=:80
- --entryPoints.websecure.address=:443
- --entrypoints.dnstcp.address=:53/tcp
- --entrypoints.dnsudp.address=:53/udp
network_mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${DOCKER_DATA}/traefik:/etc/traefik/
whoami:
container_name: whoami
image: traefik/whoami
labels:
- traefik.enable=true
- traefik.http.routers.whoami.entrypoints=web
- traefik.http.routers.whoami.rule=Host(`raspy.local`) && Path(`/whoami`)
networks:
- home_network
So far everything seems to work, because when I go to http://raspy.local/whoami I land on the whoami page. Perfect. But now I cannot seem to be able to make this work with any other container. For instance, here's Grafana:
[continues from file above]
grafana:
container_name: grafana
image: grafana/grafana
labels:
- traefik.enable=true
- traefik.http.routers.grafana.entrypoints=web
- traefik.http.routers.grafana.rule=Host(`raspy.local`) && Path(`/grafana`)
- traefik.http.services.grafana.loadbalancer.server.port=3000
networks:
- home_network
In this case when I go to http://raspy.local/grafana
I get 404 page not found
. Another example, influxDB:
[continues from file above]
influxdb:
container_name: influxdb
image: influxdb:latest
volumes:
- ${DOCKER_DATA}/influxdb/data:/var/lib/influxdb2
- ${DOCKER_DATA}/influxdb/influxdb.conf:/etc/influxdb2/config.yml:ro
environment:
- INFLUXDB_ADMIN_USER=${INFLUXDB_USERNAME} # from .env
- INFLUXDB_ADMIN_PASSWORD=${INFLUXDB_PASSWORD}. # from .env
labels:
- traefik.enable=true
- traefik.http.routers.influx.entrypoints=web
- traefik.http.routers.influx.rule=Host(`raspy.local`) && Path(`/influxdb`)
- traefik.http.services.influx.loadbalancer.server.port=8086
networks:
- home_network
This time when I go to http://raspy.local/influxdb
I see a blank page, but the web inspector shows that
I haven't had any luck with other containers as well. what am I missing??