首页 > 解决方案 > 使用 traefik 2.0 部署 docker servce 到 swarm

问题描述

我有一个 docker swarm,其网络名称为:traefik-net 类型:覆盖范围:swarm

然后我有一个 docker compose 可以工作。

services:
  angularDocs:
    image: artifactory.company.com/containers/angular-docs:branchName
    networks:
      - traefik-net
    labels:
      - "traefik.http.routers.angularDocs.rule=Host(`branchName.angular.swarm.company.com`)"
      - "traefik.http.services.angularDocs.loadbalancer.server.port=80"

networks:
  traefik-net:
    external: true
´´´

But instead of creating a compose file for each container image. I would like to do 
docker service create --options artifactory.company.com/containers/angular-docs:branchName 

但是当我这样尝试时,它不适用于 traefik

docker service create --name angulardocs  --label "traefik.http.routers.angulardocs.rule=Host(`branchName.angular.swarm.company.com`)" --label "traefik.http.services.angulardocs.loadbalancer.server.port=80" --network traefik-net artifactory.company.com/containers/angular-docs:branchName 

在 traefik 2.0 我得到了一条路线

主机(angulardocs-1-egyumq4nfke1lz3ohya38mwsj

而不是主机(v8.angular.company.com

与标签位于撰写文件中时相比,标签配置错误。

我希望有人有答案。

标签: dockerdeploymenttraefikswarm

解决方案


也许你失去了一个“入口点”。如下所示:

- "traefik.http.routers.angularDocs.entrypoints=http # I don't know your entrypoints name

推荐阅读