New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker swarm mode not discovering services without explicitly setting traefik.port property. #1388

Closed
ammaskartik opened this Issue Apr 5, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@ammaskartik

ammaskartik commented Apr 5, 2017

What version of Traefik are you using (traefik version)?

Latest Docker Traefik version traefik:latest

What is your environment & configuration (arguments, toml...)?

Docker swarm mode. OSX,

docker service create \   
    --name traefik \
    --constraint=node.role==manager \
    --publish 80:80 --publish 8080:8080 \
    --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
    --network traefik-net \
    traefik \
    --docker \
    --docker.swarmmode \
    --docker.domain=traefik \
    --docker.watch \
    --web

What did you do?

Added a service:

docker service create \
  --name whoami0 \
  --label traefik.weight=10 \
  --label traefik.frontend.rule=PathPrefix:/whoami \
  --label traefik.backend.loadbalancer.method=drr \
  --label traefik.backend.loadbalancer.swarm=true \
  --label traefik.enable=true  \
  --network traefik-net \
  -p 8000:8000 jwilder/whoami

or even using:

docker service create \
  --name whoami0 \
  --label traefik.weight=10 \
  --label traefik.frontend.rule=PathPrefix:/whoami \
  --label traefik.backend.loadbalancer.method=drr \
  --label traefik.backend.loadbalancer.swarm=true \
  --label traefik.enable=true \
  --network traefik-net \
  -p :8000 jwilder/whoami

What did you expect to see?

Adding the above service, i would expect Traefik to pick it up, whether or not i explicitly publish a port or let docker pick a random port in the default port range 30000+.

What did you see instead?

Without explicitly adding the traefik.port label traefik doesnt discover the port, I looked at the docker go code in the provider directory and it looks like Traefik tries to look at the ports property for the container, but this definitely looks like its not working at least for me. Is this by design, and if so how do you get it to work when u let docker publish a random port, or am I missing/not understanding something. Any help is appreciated.

If applicable, please paste the log output in debug mode (--debug switch)

time="2017-04-05T13:36:37Z" level=debug msg="Filtering container without port and no traefik.port label traefik.1" 
time="2017-04-05T13:36:37Z" level=debug msg="Configuration received from provider docker: {}" 
time="2017-04-05T13:36:37Z" level=info msg="Skipping same configuration for provider docker" 
time="2017-04-05T13:36:52Z" level=debug msg="Filtering container without port and no traefik.port label traefik.1" 
time="2017-04-05T13:36:52Z" level=debug msg="Configuration received from provider docker: {}" 
time="2017-04-05T13:36:52Z" level=info msg="Skipping same configuration for provider docker" 
time="2017-04-05T13:37:07Z" level=debug msg="Filtering container without port and no traefik.port label traefik.1" 
time="2017-04-05T13:37:07Z" level=debug msg="Configuration received from provider docker: {}" 
time="2017-04-05T13:37:07Z" level=info msg="Skipping same configuration for provider docker" 
time="2017-04-05T13:37:22Z" level=debug msg="Filtering container without port and no traefik.port label traefik.1" 
time="2017-04-05T13:37:22Z" level=debug msg="Configuration received from provider docker: {}" 
time="2017-04-05T13:37:22Z" level=info msg="Skipping same configuration for provider docker" 

@ammaskartik ammaskartik changed the title from Docker swarm mode Port empty? to Docker swarm mode not discovering services with explicitly setting traefik.port property. Apr 5, 2017

@ammaskartik ammaskartik changed the title from Docker swarm mode not discovering services with explicitly setting traefik.port property. to Docker swarm mode not discovering services without explicitly setting traefik.port property. Apr 5, 2017

@ammaskartik

This comment has been minimized.

ammaskartik commented Apr 5, 2017

Looking at Docker issues logs, looks like the following issue discusses why this is happening:
moby/moby#26817

Should look into looking at the service and not the container for the exposed port if needed, as I would like to use random docker gen ports, so this will mean i wont have it b4 hand. I will work around it for now; but would love to see this added; I could help in implementation if needed.

@pascalandy

This comment has been minimized.

Contributor

pascalandy commented Jun 11, 2017

Simple question. Why do you need those 2 arguments as my setup works without them?

  --label traefik.backend.loadbalancer.swarm=true \
  --label traefik.enable=true \

@ldez ldez added the kind/question label Jun 13, 2017

@nmengin

This comment has been minimized.

Member

nmengin commented Jun 13, 2017

@ammaskartik Did you try to :

  • Only expose the port 8000 into your whoami container (option --expose) and
  • Add the label traefik.port=8000 into your whoami container (to specify explicitly the port to contact from Traefik container) and
  • Add the label traefik.docker.network=traefik-net into your whoami container (to specify explicitly the network to use by Traefik container)?

More information about the Docker traefik label in the documentation.

@traefiker

This comment has been minimized.

traefiker commented Sep 24, 2017

I'll close the issue due to inactivity but feel free to re-open if needed.

@pascalandy

This comment has been minimized.

Contributor

pascalandy commented Sep 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment