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

Traefik does not attach itself to provided docker networks. #10656

Open
2 tasks done
chrisbecke opened this issue Apr 24, 2024 · 4 comments
Open
2 tasks done

Traefik does not attach itself to provided docker networks. #10656

chrisbecke opened this issue Apr 24, 2024 · 4 comments

Comments

@chrisbecke
Copy link

chrisbecke commented Apr 24, 2024

Welcome!

  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've searched similar issues on the Traefik community forum and didn't find any.

What did you do?

  1. I deployed Traefik to my docker desktop instance using the provided compose file
  2. I browsed to "http://traefik.localtest.me" and got the Traefik dashboard.
  3. I browsed to "http://whoami.localtest.me" and received a gateway timeout

What did you see instead?

I expected to see the output from whoami in the 3rd step.

It seems Traefik is not using the provided docker network via the traefik.docker.networklabel to attach itself.

What version of Traefik are you using?

v3.0

What is your environment & configuration?

compose.yaml

networks:
  traefik:
    attachable: true
  other:
    attachable: true
    name: other
services:
  traefik:
    image: traefik:v3.0
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    ports:
    - 80:80
    labels:
      traefik.enable: "true"
      traefik.http.services.traefik.loadbalancer.server.port: 8080
      traefik.http.routers.traefik.rule: HostRegexp(`^traefik.*`)
  whoami:
    image: traefik/whoami
    networks:
      - other
    labels:
      traefik.enable: "true"
      traefik.docker.network: other
      traefik.http.routers.whoami.rule: HostRegexp(`^whoami.*`)

If applicable, please paste the log output in DEBUG level

❯ docker compose up
[+] Building 0.0s (0/0)                                                                                                                                                                                                                docker:desktop-linux
[+] Running 2/2
 ✔ Container demo-traefik-traefik-1  Recreated                                                                                                                                                                                                         0.1s 
 ✔ Container demo-traefik-whoami-1   Created                                                                                                                                                                                                           0.0s 
Attaching to demo-traefik-traefik-1, demo-traefik-whoami-1
demo-traefik-whoami-1   | 2024/04/24 05:58:12 Starting up on port 80
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/cmd/traefik/traefik.go:100 > Traefik version 3.0.0-rc5 built on 2024-04-11T16:27:55Z version=3.0.0-rc5
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/cmd/traefik/traefik.go:107 > Static configuration loaded [json] staticConfiguration={"api":{"dashboard":true,"insecure":true},"entryPoints":{"http":{"address":":80","forwardedHeaders":{},"http":{},"http2":{"maxConcurrentStreams":250},"transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s","readTimeout":"1m0s"}},"udp":{"timeout":"3s"}},"traefik":{"address":":8080","forwardedHeaders":{},"http":{},"http2":{"maxConcurrentStreams":250},"transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s","readTimeout":"1m0s"}},"udp":{"timeout":"3s"}}},"global":{"checkNewVersion":true},"log":{"format":"common","level":"DEBUG"},"providers":{"docker":{"defaultRule":"Host(`{{ normalize .Name }}`)","endpoint":"unix:///var/run/docker.sock","exposedByDefault":true,"watch":true},"providersThrottleDuration":"2s"},"serversTransport":{"maxIdleConnsPerHost":200},"tcpServersTransport":{"dialKeepAlive":"15s","dialTimeout":"30s"}}
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/cmd/traefik/traefik.go:605 > 
demo-traefik-traefik-1  | Stats collection is disabled.
demo-traefik-traefik-1  | Help us improve Traefik by turning this feature on :)
demo-traefik-traefik-1  | More details on: https://doc.traefik.io/traefik/contributing/data-collection/
demo-traefik-traefik-1  | 
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:73 > Starting provider aggregator aggregator.ProviderAggregator
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/server_entrypoint_tcp.go:220 > Starting TCP Server entryPointName=traefik
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/server_entrypoint_tcp.go:220 > Starting TCP Server entryPointName=http
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *traefik.Provider
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *traefik.Provider provider configuration config={}
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *acme.ChallengeTLSALPN
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *acme.ChallengeTLSALPN provider configuration config={}
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z INF github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:202 > Starting provider *docker.Provider
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/provider/aggregator/aggregator.go:203 > *docker.Provider provider configuration config={"defaultRule":"Host(`{{ normalize .Name }}`)","endpoint":"unix:///var/run/docker.sock","exposedByDefault":true,"watch":true}
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{"middlewares":{"dashboard_redirect":{"redirectRegex":{"permanent":true,"regex":"^(http:\\/\\/(\\[[\\w:.]+\\]|[\\w\\._-]+)(:\\d+)?)\\/$","replacement":"${1}/dashboard/"}},"dashboard_stripprefix":{"stripPrefix":{"prefixes":["/dashboard/","/dashboard"]}}},"routers":{"api":{"entryPoints":["traefik"],"priority":9223372036854775806,"rule":"PathPrefix(`/api`)","service":"api@internal"},"dashboard":{"entryPoints":["traefik"],"middlewares":["dashboard_redirect@internal","dashboard_stripprefix@internal"],"priority":9223372036854775805,"rule":"PathPrefix(`/`)","service":"dashboard@internal"}},"serversTransports":{"default":{"maxIdleConnsPerHost":200}},"services":{"api":{},"dashboard":{},"noop":{}}},"tcp":{"serversTransports":{"default":{"dialKeepAlive":"15s","dialTimeout":"30s"}}},"tls":{},"udp":{}} providerName=internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/provider/docker/pdocker.go:89 > Provider connection established with docker 24.0.6 (API 1.43) providerName=docker
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:227 > Configuration received config={"http":{"routers":{"traefik":{"rule":"HostRegexp(`^traefik.*`)","service":"traefik"},"whoami":{"rule":"HostRegexp(`^whoami.*`)","service":"whoami-demo-traefik"}},"services":{"traefik":{"loadBalancer":{"passHostHeader":true,"responseForwarding":{"flushInterval":"100ms"},"servers":[{"url":"http://172.28.0.2:8080"}]}},"whoami-demo-traefik":{"loadBalancer":{"passHostHeader":true,"responseForwarding":{"flushInterval":"100ms"},"servers":[{"url":"http://172.29.0.2:80"}]}}}},"tcp":{},"tls":{},"udp":{}} providerName=docker
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/stripprefix/strip_prefix.go:32 > Creating middleware entryPointName=traefik middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/observability/middleware.go:33 > Adding tracing to middleware entryPointName=traefik middlewareName=dashboard_stripprefix@internal routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/redirect/redirect_regex.go:17 > Creating middleware entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/redirect/redirect_regex.go:18 > Setting up redirection from ^(http:\/\/(\[[\w:.]+\]|[\w\._-]+)(:\d+)?)\/$ to ${1}/dashboard/ entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/observability/middleware.go:33 > Adding tracing to middleware entryPointName=traefik middlewareName=dashboard_redirect@internal routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:22 > Creating middleware entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/aggregator.go:51 > No entryPoint defined for this router, using the default one(s) instead entryPointName=["http"] routerName=whoami
demo-traefik-traefik-1  | 2024-04-24T05:58:12Z DBG github.com/traefik/traefik/v3/pkg/server/aggregator.go:51 > No entryPoint defined for this router, using the default one(s) instead entryPointName=["http"] routerName=traefik
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/tls/tlsmanager.go:321 > No default certificate, fallback to the internal generated certificate tlsStoreName=default
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:259 > Creating load-balancer entryPointName=http routerName=whoami@docker serviceName=whoami-demo-traefik@docker
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:301 > Creating server entryPointName=http routerName=whoami@docker serverName=3d2ab0f52d9842f2 serviceName=whoami-demo-traefik@docker target=http://172.29.0.2:80
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:259 > Creating load-balancer entryPointName=http routerName=traefik@docker serviceName=traefik@docker
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/server/service/service.go:301 > Creating server entryPointName=http routerName=traefik@docker serverName=8da56afeb5a27187 serviceName=traefik@docker target=http://172.28.0.2:8080
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:22 > Creating middleware entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/stripprefix/strip_prefix.go:32 > Creating middleware entryPointName=traefik middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/observability/middleware.go:33 > Adding tracing to middleware entryPointName=traefik middlewareName=dashboard_stripprefix@internal routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/redirect/redirect_regex.go:17 > Creating middleware entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/redirect/redirect_regex.go:18 > Setting up redirection from ^(http:\/\/(\[[\w:.]+\]|[\w\._-]+)(:\d+)?)\/$ to ${1}/dashboard/ entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/observability/middleware.go:33 > Adding tracing to middleware entryPointName=traefik middlewareName=dashboard_redirect@internal routerName=dashboard@internal
demo-traefik-traefik-1  | 2024-04-24T05:58:13Z DBG github.com/traefik/traefik/v3/pkg/middlewares/recovery/recovery.go:22 > Creating middleware entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
demo-traefik-traefik-1  | 2024-04-24T05:59:20Z DBG github.com/traefik/traefik/v3/pkg/server/service/loadbalancer/wrr/wrr.go:196 > Service selected by WRR: 3d2ab0f52d9842f2
demo-traefik-traefik-1  | 2024-04-24T05:59:40Z DBG github.com/traefik/traefik/v3/pkg/server/service/loadbalancer/wrr/wrr.go:196 > Service selected by WRR: 8da56afeb5a27187
demo-traefik-traefik-1  | 2024-04-24T05:59:40Z DBG github.com/traefik/traefik/v3/pkg/server/service/loadbalancer/wrr/wrr.go:196 > Service selected by WRR: 8da56afeb5a27187
demo-traefik-traefik-1  | 2024-04-24T05:59:50Z DBG github.com/traefik/traefik/v3/pkg/server/service/proxy.go:100 > 504 Gateway Timeout error="dial tcp 172.29.0.2:80: i/o timeout"
@Yaytay
Copy link

Yaytay commented Jun 10, 2024

This would be great to see, but would need write access to the docker config - making things like wollomatic/socket-proxy more complex (hopefully not impossible).

@nmengin
Copy link
Contributor

nmengin commented Jun 10, 2024

Hello @chrisbecke,

Thanks for reaching out.
The behavior you describe comes from a limitation inside Docker.

A container cannot be attached to a network after its creation without being restarted.
The option traefik.docker.network only allows your Traefik instance to know what network to use to reach your backend.
But in no case, does it allow modifying the configuration of its container.

I recommend you take a look in the community forum. It is pretty active, so you might find that your question has already been answered there. If not, you can ask and get help from other community members pretty quickly.

@chrisbecke
Copy link
Author

chrisbecke commented Jun 11, 2024

A container cannot be attached to a network after its creation without being restarted.

See now heres the thing. There are a lot of things about containers that do require a restart.

Networks however are, ironically, one of the resources that can be added on the fly

See docker network connect <network> <container>, Or the api.

"re-attaching" networks to running containers is called out as problematic, so "add, remove, add" will need to be avoided.

@nmengin nmengin self-assigned this Jun 13, 2024
@nmengin
Copy link
Contributor

nmengin commented Jun 13, 2024

Hello @chrisbecke,

I re-opened the issue to make some checks according to your previous message.

@nmengin nmengin reopened this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants