docker - traefik 路由到侦听不同端口的容器
问题描述
我有以下 traefik 设置。
路由到whoami
和phpunit
容器完美运行。但是allure
容器想要在端口上运行5050
,我不知道如何路由到该端口。
version: '3'
services:
traefik:
container_name: traefik
image: traefik:v2.4
command:
- --api.insecure=true
- --providers.docker
- --providers.docker.useBindPortIP=true
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Path(`/whoami`)"
phpunit:
image: nginx
volumes:
- /home/ci/phpunit:/usr/share/nginx/html
labels:
- "traefik.http.routers.phpunit.rule=PathPrefix(`/phpunit/`)"
allure:
image: frankescobar/allure-docker-service
environment:
- CHECK_RESULTS_EVERY_SECONDS=3
- KEEP_HISTORY=1
volumes:
- /home/ci/allure/allure_results:/app/allure-results
- /home/ci/allure/allure_reports:/app/default-reports
labels:
- "traefik.http.routers.allure.rule=PathPrefix(`/allure/`)"
- "traefik.http.services.allure.loadbalancer.server.port=5050"
如果我直接用 - 暴露诱惑容器,5050:5050
我可以用http://example.com:5050
. 但是使用上面的配置http://example.com/allure/
会返回一个 404 页面(allure
来自 traefik,而不是来自 traefik)。
我使用--providers.docker.useBindPortIP=true
并traefik.http.services.SERVICE.loadbalancer.server.port=5050
从这里了解到:Traefik v2 [如何路由到特定端口]
还有更多提示我可以尝试什么吗?
解决方案
推荐阅读
- java - 总是在 JDBI 中使用事务有什么明显的缺点吗?
- python - Selenium python 说 textarea 不可交互
- xml - 如何从 XSL 3.0 映射中获取字符串
- php - Consolibyte Quickbooks 集成一般问题
- python - - [SSL: CERTIFICATE_VERIFY_FAILED] 在 Linux 上使用 BeautifulSoup4 时
- kdb - 为什么我的计数不起作用,但从 hdb 中选择就可以了?
- arrays - 访问嵌套数组以快速填充表格视图
- multithreading - 线程中的事件到底是什么?
- encryption - 使用 ECIES 进行文件加密
- server - 克隆网站的问题 - 克隆中缺少域托管信息