【发布时间】:2020-04-14 08:20:43
【问题描述】:
开始学习 docker,traefik 在家玩。
目标:将所有内容放在docker-compose.yml 和.env 文件中,了解基础知识,并据此发表评论。
想要从traefik.test.local/dashboard而不是test.local:8080获取仪表板,同样应该从traefik.test.local/api访问api。这样就不必考虑端口号了。
向/etc/hosts添加行
127.0.0.1 test.local
127.0.0.1 traefik.test.local
docker-compose.yml
version: "3.7"
services:
traefik:
# The official v2 Traefik docker image
image: traefik:v2.2
# Lets name the container
container_name: traefik
command:
# Enables the web UI
- "--api.insecure=true"
# Tells Traefik to listen to docker
- "--providers.docker"
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
#labels:
#- "traefik.http.routers.router.rule=Host(`traefik.test.local/dashboard`)"
#- "traefik.http.routers.router.rule=Host(`traefik.test.local/api`)"
restart:
always
无法理解如何从路由器连接到服务。如果我在任何地方错了,也请纠正我。谢谢。
PS:操作系统:kde-neon
【问题讨论】: