当服务部署到 docker swarm 时 Traefik 不更新
Traefik not updating when services are deployed to docker swarm
我在 docker 中有一个 traefik 环境 运行。最初我是 运行 标准容器中的服务。我没有将容器部署到 docker 群,我也为 traefik 做了这个,容器只部署到我的群管理器。
不知为何,traefik成功注册了我给它的主机名,并且可以正常访问了。
但是,当我将任何其他服务部署到 swarm 时,traefik 不会接收它。
还有一项服务已经部分起作用。我已将 heimdall 部署到 docker swarm,可以从 gateway.docker.swarm:8091 访问,但我也不想要该端口。
我的traefik compose文件如下:
version: '3.3'
networks:
swarm-network:
driver: overlay
services:
traefik:
# The official v2 Traefik docker image
image: traefik
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.docker.network=pi_swarm-network"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
- "traefik.http.routers.traefik.rule=Host(`traefik.docker.swarm`)"
# Enables the web UI and tells Traefik to listen to docker
command:
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.swarmmode=true'
- '--providers.docker.defaultRule=Host("docker.swarm")'
- '--providers.docker.watch=true'
- '--providers.docker.swarmModeRefreshSeconds=15s'
# Metrics configuration for influx db.
- '--metrics=true'
- '--metrics.influxdb=true'
- '--metrics.influxdb.address=192.168.8.122:8086'
- '--metrics.influxdb.protocol=http'
- '--metrics.influxdb.database=traefik'
- '--metrics.influxdb.addEntryPointsLabels=true'
- '--metrics.influxdb.addServicesLabels=true'
- '--metrics.influxdb.pushInterval=10s'
# Tracing
- '--tracing=true'
- '--tracing.zipkin=true'
- '--tracing.zipkin.httpEndpoint=http://192.168.8.117:9411/api/v2/spans'
- '--log'
- '--accesslog'
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
networks:
- swarm-network
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
我是 运行 的另一项服务的示例是 heimdall,它具有以下组成文件:
version: "3"
networks:
swarm-network:
external:
name: pi_swarm-network
services:
heimdall:
image: ghcr.io/linuxserver/heimdall
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
deploy:
placement:
constraints:
- node.labels.tier == web
labels:
- "traefik.enable=true"
- "traefik.docker.network=pi_swarm-network"
- "traefik.http.routers.heimdall.entrypoints=http"
- "traefik.http.services.heimdall.loadbalancer.server.port=8091"
- "traefik.http.routers.heimdall.rule=Host(`gateway.docker.swarm`)"
ports:
- 8091:80
restart: unless-stopped
networks:
- swarm-network
谁能看出我做错了什么?
我找到问题了
在我的撰写文件中,我使用的是“traefik.http.services.heimdall.loadbalancer.entrypoints=http”
也
"traefik.http.routers.heimdall.entrypoints=http"
这是不正确的,需要只是
"traefik.http.routers.heimdall.entrypoints=http"
对于 heimdall,我还针对 8091 的外部端口,而实际上我需要针对 80 的内部端口
我在 docker 中有一个 traefik 环境 运行。最初我是 运行 标准容器中的服务。我没有将容器部署到 docker 群,我也为 traefik 做了这个,容器只部署到我的群管理器。
不知为何,traefik成功注册了我给它的主机名,并且可以正常访问了。 但是,当我将任何其他服务部署到 swarm 时,traefik 不会接收它。 还有一项服务已经部分起作用。我已将 heimdall 部署到 docker swarm,可以从 gateway.docker.swarm:8091 访问,但我也不想要该端口。
我的traefik compose文件如下:
version: '3.3'
networks:
swarm-network:
driver: overlay
services:
traefik:
# The official v2 Traefik docker image
image: traefik
deploy:
placement:
constraints:
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.docker.network=pi_swarm-network"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
- "traefik.http.routers.traefik.rule=Host(`traefik.docker.swarm`)"
# Enables the web UI and tells Traefik to listen to docker
command:
- '--api.insecure=true'
- '--providers.docker=true'
- '--providers.docker.swarmmode=true'
- '--providers.docker.defaultRule=Host("docker.swarm")'
- '--providers.docker.watch=true'
- '--providers.docker.swarmModeRefreshSeconds=15s'
# Metrics configuration for influx db.
- '--metrics=true'
- '--metrics.influxdb=true'
- '--metrics.influxdb.address=192.168.8.122:8086'
- '--metrics.influxdb.protocol=http'
- '--metrics.influxdb.database=traefik'
- '--metrics.influxdb.addEntryPointsLabels=true'
- '--metrics.influxdb.addServicesLabels=true'
- '--metrics.influxdb.pushInterval=10s'
# Tracing
- '--tracing=true'
- '--tracing.zipkin=true'
- '--tracing.zipkin.httpEndpoint=http://192.168.8.117:9411/api/v2/spans'
- '--log'
- '--accesslog'
ports:
# The HTTP port
- "80:80"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
networks:
- swarm-network
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
我是 运行 的另一项服务的示例是 heimdall,它具有以下组成文件:
version: "3"
networks:
swarm-network:
external:
name: pi_swarm-network
services:
heimdall:
image: ghcr.io/linuxserver/heimdall
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
deploy:
placement:
constraints:
- node.labels.tier == web
labels:
- "traefik.enable=true"
- "traefik.docker.network=pi_swarm-network"
- "traefik.http.routers.heimdall.entrypoints=http"
- "traefik.http.services.heimdall.loadbalancer.server.port=8091"
- "traefik.http.routers.heimdall.rule=Host(`gateway.docker.swarm`)"
ports:
- 8091:80
restart: unless-stopped
networks:
- swarm-network
谁能看出我做错了什么?
我找到问题了
在我的撰写文件中,我使用的是“traefik.http.services.heimdall.loadbalancer.entrypoints=http” 也 "traefik.http.routers.heimdall.entrypoints=http"
这是不正确的,需要只是 "traefik.http.routers.heimdall.entrypoints=http"
对于 heimdall,我还针对 8091 的外部端口,而实际上我需要针对 80 的内部端口