Traefik can connect with docker-compose, but not with swarm services on windows

Viewed 449

Having trouble networking docker swarm services with traefik on windows server 2016. I've tried everything I can think of and ended up getting a docker-compose to work with the nat network, however I plan on launching more apps through swarm services and can't seem to connect traefik and the services with the docker-compose network.

Any help is appreciated

I've tried creating a new overlay network. Connecting the services without a network which defaults to nat (as I can inspect nat and see the services connected), but still can't access the app the same way I can using docker-compose.

When I run docker ps this is the output.

CONTAINER ID        IMAGE                                  COMMAND                   CREATED             STATUS              PORTS                                        NAMES
e9bb15daf909        stefanscherer/traefik-windows:latest   "/traefik --configfi…"    13 seconds ago      Up 8 seconds        80/tcp                                       traefik-test.ya54gf7ggrwpxk7hb2apyt87u.9t7n20hy2xyq80dtovp280u8t
26eccf39f07e        stefanscherer/whoami                   "\\http.exe"              23 seconds ago      Up 18 seconds       8080/tcp                                     traefik_whoami_1
ed95b99fae35        stefanscherer/traefik-windows          "/traefik --configfi…"    23 seconds ago      Up 17 seconds       0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp   traefik_proxy_1

As you can see the ports of the two traefik process are different.

Below are the working docker-compose and non-working service commands.

docker-compose.yaml

services:
  proxy:
    image: stefanscherer/traefik-windows
    command: --api --docker --logLevel=WARN --docker.endpoint=tcp://XXX.XX.XXX.X:2375
    networks:
      - default
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - E:/docker/traefik:C:/etc/traefik
  whoami:
    image: stefanscherer/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.backend=whoami"
      - "traefik.frontend.rule=PathStrip: /whoami/"

networks:
  default:
    external:
      name: nat

Individual swarm services

docker service create `
  --name whoami `
  --label traefik.enable=true `
  --label traefik.backend=whoami `
  --label traefik.frontend.rule=PathPrefixStrip:/whoami `
  --label traefik.port=80 `
  stefanscherer/whoami

docker service create `
  --name traefik-test `
  --mode global `
  --constraint=node.role==manager `
  --publish 8080:8080 `
  --publish 80:80 `
  stefanscherer/traefik-windows  `
  --defaultentrypoints="http" `
  --retry `
  --debug=true `
  --logLevel=DEBUG `
  --docker `
  --docker.endpoint=tcp://XXX.XX.XXX.X:2375 `
  --docker.swarmmode `
  --docker.domain=traefik `
  --docker.watch `
  --docker.exposedbydefault=false `
  --web `
  --web.statistics

Expected results:

Visiting http://SERVER:8080/ should bring up the traefik dashboard as it does when I do docker-compose.

Actual results:

Visiting http://SERVER:80 or http://SERVER:8080 the webpage hangs and never loads.

1 Answers

I managed to get it working in swarm. See my question here for details.

Related