Traefik with Docker Stack doesn't detect port

0 votes

I'm trying to deploy a website using docker and traefik. When i deploy the service manually it works perfectly fine but I'm not able to deploy it using docker stack.

My docker compose file:

version: "3.6"
services:
  site:
    ports:
      - 4000:4000
    image: mywebsite:latest
    labels:
      - traefik.site.port=4000
      - traefik.enable=true
      - traefik.frontend.rule=Host:mydomain.com
    networks: 
      - traefik-net

  reverse-proxy:
    image: traefik # The official Traefik docker image
    ports:
      - "80:80"     # The HTTP port
      - "8080:8080" # The Web UI (enabled by --api)
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - $PWD/traefik.toml:/etc/traefik/traefik.toml
    deploy:
      labels:
        traefik.logLevel: 'DEBUG'
      placement:
        constraints:
          - node.role == manager
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure
    networks:
      - traefik-net

networks: 
  traefik-net:
    name: traefik-net
Aug 29, 2018 in Kubernetes by lina
• 8,110 points
180 views

1 answer to this question.

0 votes

When using traefik configured for swarm mode, set the label on the service instaed of the container. You do that by moving the labels inside of a deploy block in the compose file:

services:
  site:
    ports:
      - 4000:4000
    image: mywebsite:latest
    deploy:
      labels:
        - traefik.site.port=4000
        - traefik.enable=true
        - traefik.frontend.rule=Host:mydomain.com
    networks: 
      - traefik-net
answered Aug 29, 2018 by Kalgi
• 40,440 points

Related Questions In Kubernetes

0 votes
1 answer

Using local docker images with Minikube

You can reuse the Docker daemon from ...READ MORE

answered Jan 3 in Kubernetes by ajs3033
• 7,280 points
410 views
0 votes
1 answer
0 votes
2 answers

Kubernetes Docker logs

To tail the logs, use the -foption kubectl logs ...READ MORE

answered Sep 6, 2018 in Kubernetes by Nilesh
• 6,880 points
46 views
+3 votes
3 answers

local docker image on minikube

Try something like this: # Start minikube minikube start # ...READ MORE

answered Aug 29, 2018 in Kubernetes by Nilesh
• 6,880 points
5,673 views
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
999 views
0 votes
1 answer
0 votes
1 answer

Kubernetes Endpoints with TTL

Follow these steps: add an annotation to each ...READ MORE

answered Aug 27, 2018 in Kubernetes by Kalgi
• 40,440 points
47 views
0 votes
1 answer

Traefik: Forward Authentication not working

Look at the 7th line of your ...READ MORE

answered Aug 27, 2018 in Kubernetes by Kalgi
• 40,440 points
1,286 views