[英]Serving Swagger UI and editor using Docker Compose and Traefik
My first attempt to start and use Swagger UI and Swagger Editor in the same time.我第一次尝试同时启动和使用 Swagger UI 和 Swagger Editor。 My approach is to define two services using Docker Compose and hiding them behind a reverse proxy, in this case Traefik.我的方法是使用 Docker Compose 定义两个服务并将它们隐藏在反向代理后面,在本例中为 Traefik。
But, something is wrong with my compose file and I can't figure out.但是,我的撰写文件有问题,我无法弄清楚。
version: '3'
services:
traefik:
image: traefik:v2.5
restart: always
command:
- --accesslog
- --api.insecure=true
- --providers.docker
- --providers.docker.exposedbydefault=false
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "80:80"
- "8080:8080"
swaggerui:
image: swaggerapi/swagger-ui
restart: always
environment:
- PORT=8081
expose:
- 8081
labels:
- traefik.enable=true
- traefik.http.routers.swaggerui.rule=Host(`swaggerui`) && Path(`/ui`)
swaggereditor:
image: swaggerapi/swagger-editor
restart: always
environment:
- PORT=8082
expose:
- 8082
labels:
- traefik.enable=true
- traefik.http.routers.swaggereditor.rule=Host(`swaggereditor`) && Path(`/editor`)
Any suggestion?有什么建议吗?
KI基
You have to specify named entrypoint address (actually port number in container) in Traefik configuration at first您必须首先在 Traefik 配置中指定命名入口点地址(实际上是容器中的端口号)
command:
...
- "--entrypoints.swaggerui.address=:8081"
At the second step you should add label for swaggerui container, just like this在第二步,你应该为swaggerui容器添加 label,就像这样
labels:
- "traefik.enable=true"
- "traefik.http.routers.swaggerui.entrypoints=swaggerui"
...
After the above steps, everything should work完成上述步骤后,一切正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.