Traefik未将后端/前端设置为swarm模式

Traefik未将后端/前端设置为swarm模式,traefik,Traefik,我想在集群群中使用traefik,根据本指南,我编写了以下堆栈文件: traefik: image: traefik:alpine deploy: placement: constraints: - node.role == manager command: --api --docker --docker.watch --docker.swarmMode volumes: - /var/run/doc

我想在集群群中使用traefik,根据本指南,我编写了以下堆栈文件:

  traefik:
    image: traefik:alpine
    deploy:
      placement:
        constraints:
          - node.role == manager
    command: --api --docker --docker.watch --docker.swarmMode
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - "80:80"
      - "8080:8080"
    labels:
      - "traefik.enable=false"

  backend:
    image: registry.example.com/backend
    labels:
      - "traefik.backend=backend"
      - "traefik.backend.buffering.maxRequestBodyBytes=2147483648"
      - "traefik.backend.loadbalancer.sticky=true"
      - "traefik.frontend.rule=Host:backend.localhost"
      - "traefik.frontend.passHostHeader=true"
      - "traefik.port=80" 

   api:
    image: registry.example.com/api
    labels:
      - "traefik.backend=api"
      - "traefik.backend.buffering.maxRequestBodyBytes=2147483648"
      - "traefik.backend.loadbalancer.sticky=true"
      - "traefik.frontend.rule=Host:api.localhost"
      - "traefik.frontend.passHostHeader=true"
      - "traefik.port=80"
Traefik启动但未配置任何内容,我无法理解错误在哪里


您忘记了示例中的网络部分。 您丢失了与网络相关的标签和网络的LELF:

  deploy:
    labels:
    - "traefik.docker.network=traefik-network" # for both api and backend
    ...
  networks:
  - "traefik-network" # for traefik, api and backend
  ...
networks:
  traefik-network:{} # you can also make it external
编辑:
另外,在swarm上,标签应该设置在服务的“部署”部分下,而不是服务本身。

网络部分存在,我省略了……问题是
标签
定义,在
部署
工作中。谢谢