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,220 points
1,539 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
• 52,350 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, 2019 in Kubernetes by ajs3033
• 7,300 points
2,876 views
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
• 7,060 points
854 views
+5 votes
4 answers

local docker image on minikube

I know this is an old question ...READ MORE

answered Feb 1, 2020 in Kubernetes by anonymous
25,048 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
3,932 views
+2 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
• 52,350 points
779 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
• 52,350 points
4,122 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP