问题
I want to run traefik on a docker swarm cluster powered by Windows Server 2019.
It works while using docker network create
and docker service create
commands directly.
But a seemingly identical compose file does not work. Any help is appreciated.
PowerShell commands:
# create network
docker network create proxy --driver overlay --subnet 11.0.0.0/24 --gateway 11.0.0.1
# start traefik
docker service create `
--name traefik `
--constraint node.role==manager `
--publish 80:80 `
--publish 8080:8080 `
--mount type=npipe,source=\\.\pipe\docker_engine,target=\\.\pipe\docker_engine `
--label traefik.port=8080 `
--network proxy `
stefanscherer/traefik-windows `
--docker `
--docker.domain=traefik `
--docker.endpoint=npipe:////./pipe/docker_engine `
--docker.network=proxy `
--docker.swarmMode `
--docker.watch `
--api `
--defaultentrypoints=http `
--entryPoints='Name:http Address::80' `
--logLevel=DEBUG
Compose file:
version: '3.7'
services:
main:
image: stefanscherer/traefik-windows:v1.7.12
networks:
- net
volumes:
# pipe is available only on manager nodes
- type: npipe
source: \\.\pipe\docker_engine
target: \\.\pipe\docker_engine
ports:
- 80:80
- 8080:8080
deploy:
placement:
constraints: [node.role == manager]
# for dynamic traefik configuration add labels here
command:
# for static traefik configuration add options here
# alternative: add configuration file via volumes
- --docker
- --docker.domain=traefik
- --docker.endpoint=npipe:////./pipe/docker_engine
- --docker.network=proxy
- --docker.swarmMode
- --docker.watch
- --api
- --defaultentrypoints=http
- --entryPoints='Name:http Address::80'
- --logLevel=DEBUG
networks:
net:
driver: overlay
name: proxy
ipam:
driver: default
config:
- subnet: 11.0.0.0/24
After posting this question, I decided it might be a docker bug and opened this issue.
来源:https://stackoverflow.com/questions/60851694/deploy-traefik-with-docker-stack-on-windows-server-2019