Skip to content
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

Dashboard does not initialize with --network="host" #5455

Closed
1 of 2 tasks
stellirin opened this issue Sep 22, 2019 · 6 comments
Closed
1 of 2 tasks

Dashboard does not initialize with --network="host" #5455

stellirin opened this issue Sep 22, 2019 · 6 comments

Comments

@stellirin
Copy link

Do you want to request a feature or report a bug?

Bug

Did you try using a 1.7.x configuration for the version 2.0?

  • Yes
  • No

What did you do?

docker run --rm \
    --name="traefik" \
    --label="traefik.enable=true" \
    --label="traefik.http.routers.traefik.entrypoints=http" \
    --label="traefik.http.routers.traefik.rule=Host(\`traefik.localhost\`)" \
    --label="traefik.http.routers.traefik.service=api@internal" \
    --volume="/var/run/docker.sock:/var/run/docker.sock" \
    --network="host" \
    traefik:2.0 \
    "--api=true" \
    "--api.dashboard=true" \
    "--log.level=DEBUG" \
    "--providers.docker=true" \
    "--providers.docker.exposedbydefault=false" \
    "--entrypoints.http.address=:80"

What did you expect to see?

Dashboard available at http://traefik.localhost:80.

What did you see instead?

time="2019-09-22T20:48:54Z" level=info msg="Configuration loaded from flags."
time="2019-09-22T20:48:54Z" level=info msg="Traefik version 2.0.0 built on 2019-09-16T17:35:17Z"
time="2019-09-22T20:48:54Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
time="2019-09-22T20:48:54Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
time="2019-09-22T20:48:54Z" level=debug msg="No default certificate, generating one"
time="2019-09-22T20:48:54Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2019-09-22T20:48:54Z" level=debug msg="Start TCP Server" entryPointName=http
time="2019-09-22T20:48:54Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
time="2019-09-22T20:48:54Z" level=debug msg="Provider connection established with docker 19.03.1 (API 1.40)" providerName=docker
time="2019-09-22T20:48:54Z" level=error msg="port is missing" providerName=docker container=/traefik-08181dbd4297d897e52e150c0748d82e571c6542553ba1932150eef02262f526
time="2019-09-22T20:48:54Z" level=debug msg="Configuration received from provider docker: {\"http\":{},\"tcp\":{}}" providerName=docker
time="2019-09-22T20:48:54Z" level=debug msg="No default certificate, generating one"

Remove --network="host" and Dashboard initializes as expected:

time="2019-09-22T20:49:46Z" level=info msg="Configuration loaded from flags."
time="2019-09-22T20:49:46Z" level=info msg="Traefik version 2.0.0 built on 2019-09-16T17:35:17Z"
time="2019-09-22T20:49:46Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
time="2019-09-22T20:49:46Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
time="2019-09-22T20:49:46Z" level=debug msg="No default certificate, generating one"
time="2019-09-22T20:49:47Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2019-09-22T20:49:47Z" level=debug msg="Start TCP Server" entryPointName=http
time="2019-09-22T20:49:47Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
time="2019-09-22T20:49:47Z" level=debug msg="Provider connection established with docker 19.03.1 (API 1.40)" providerName=docker
time="2019-09-22T20:49:47Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"traefik\":{\"entryPoints\":[\"http\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.localhost`)\"}},\"services\":{\"/traefik\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://10.255.0.2:80\"}],\"passHostHeader\":true}}}},\"tcp\":{}}" providerName=docker
time="2019-09-22T20:49:47Z" level=debug msg="Added outgoing tracing middleware api@internal" entryPointName=http middlewareName=tracing middlewareType=TracingForwarder routerName=traefik@docker
time="2019-09-22T20:49:47Z" level=debug msg="Creating middleware" entryPointName=http middlewareType=Recovery middlewareName=traefik-internal-recovery
time="2019-09-22T20:49:47Z" level=debug msg="No default certificate, generating one"

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

Version:      2.0.0
Codename:     montdor
Go version:   go1.13
Built:        2019-09-16T17:35:17Z
OS/Arch:      linux/amd64

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

N/A

If applicable, please paste the log output in DEBUG level (--log.level=DEBUG switch)

N/A
@stellirin
Copy link
Author

Seems to be from https://github.com/containous/traefik/blob/master/pkg/provider/docker/config.go#L169

Looks like it assumes a container will always have ports defined in the container metadata, but when using host networking nearly all network information is empty?

@dduportal dduportal added kind/bug/possible a possible bug that needs analysis before it is confirmed or fixed. area/api area/webui area/provider/docker and removed status/0-needs-triage labels Sep 23, 2019
@dduportal
Copy link
Contributor

dduportal commented Sep 25, 2019

Hi @stellirin , this behavior is expected, but not well documented due to the "freshness" of the release 2.0.0.

For long term, the team will document the behavior described below so the documentation will be in shape to help you understanding + might work on adapting the behavior for edge cases like this one.

In short term, you can make it work by adding the following label: traefik.http.services.workaround.loadbalancer.server.port=9999 (the value workaround can be any string, and the port value 9999 can be any strictly positive integer number).

The explanation of the behaviour, as you already figured out by reading the code is:

  • This case is specific when the Docker provider is used. Please note that Docker Swarm might have the same case.
  • When the Docker provider is used, it creates a "Service" for each container. Each "Service" has an associated loadbalancer port retrieved from the container metadata, as you saw.
  • In the specific case of the service xxx@internal everything is kept internally to Traefik instance. There is no way to set up a custom loadbalancer with custom port for these services.
  • When associating the service xxx@internal with the router at the docker container level,Traefik also creates an "empty" service not used. As this "empty service" does not have any port, the association router <-> service xxx@internal does not happen: this is the reason of setting a manual "dummy" port, so everything is wired correctly.

Hope it helps

@dduportal dduportal added area/documentation kind/enhancement a new or improved feature. and removed kind/bug/possible a possible bug that needs analysis before it is confirmed or fixed. labels Sep 25, 2019
@ldez ldez added this to issues in v2 via automation Sep 26, 2019
@traefiker traefiker added this to the 2.0 milestone Sep 26, 2019
v2 automation moved this from issues to Done Sep 26, 2019
@traefiker
Copy link
Contributor

Closed by #5493.

@stellirin
Copy link
Author

Thank you very much for the detailed explanation and the workaround. I can confirm that adding the suggested label to the traefik service allows the internal api services to start when using --network="host".

@fredericrous
Copy link

#5493 does not fix the issue

@ruimaciel
Copy link

@dduportal I'm having some problems getting traefik 2.0.2 to play well docker swarm. Is there any way to get some clarification on what's traefik's expected behavior is supposed to be when deployed as part of a docker swarm stack?

@traefik traefik locked and limited conversation to collaborators Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
v2
Done
Development

No branches or pull requests

5 participants