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
Allow Docker dynamic configuration for container with host or custom networks #5559
Comments
(Proposal written after a short discussion with @juliens ) |
Ha ! I am facing the problem as well, and was about to open an issue. From my little chair, the following shall be done: instead of returning 127.0.0.1 the line 257 should return the IP of the docker0 interface (default = 172.17.0.1). This would work in every cases (traefik & exposed container in network_mode = host, or just the exposed container in network_mode = host). The part that I haven't figured out is how to properly retrieve that IP from within the traefik container. If traefik networking mode is bridge this IP is the default gateway; if traefik is in host mode it would be the interface of the docker0 interface (but docker0 is only the default name - it can be renamed to anything...). Writing to code to achieve that while maintaining multi platform compatibility seems pretty complex. An easier approach would be to implement the following pseudo-code (sorry - I don't speak golang)
The sad part is that "host.docker.internal" is not yet available on linux (docker/for-linux#264), but it can be tackled manually in the meantime by using extra_hosts.
If someone can validate my understanding of the problem, I could try to create a PR |
This comment has been minimized.
This comment has been minimized.
I have a use case where I have some containers that need to issue Wake-on-LAN packets to other devices on the network. This works with |
I struggled to get the workaround to this solution working with homeassistant, and figured I'd share my solution for others until this issue gets addressed: https://gist.github.com/gaieges/936bdf91e01e4cc782eb047e5873089b |
Does the issue affect macvlan aswell ? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Any more thoughts on this important feature? Have a number of containers which:
In both cases, the services need to be manually set in a file provider which seems silly. The URL I use for 'http.services.XXXX-srv.loadBalancer.servers' is 'http://172.17.0.1:PORT' but really any of the valid IPv4 gateway addresses work like 'http://172.18.0.1:PORT'. Of course, we want to use the right one. Traefik should simply use the gateway on its own network (which is available via the API or even Provided that the service is created by docker, it will listen on 0.0.0.0 and be fine. So long as it doesn't bind to a specific external IP (in which case a file provider is probably needed anyway), just using the gateway for the service is the way to go. The logic would be:
|
If we are not mistaken this issue has been closed by #5698. |
Do you want to request a feature or report a bug?
Proposal/Feature
What did you expect to see?
This proposal follows #5535.
As a Traefik user with the Docker provider,
When I start a backend container with the network mode
host
(see diagram below),Then I want to configure Route and Service with labels as any Docker backend service
(N.B. one of the reason to have such a setup would be to expose a container with different network entrypoints, not only the HTTP service, or where you cannot NAT. Examples: streaming system with both TCP and UDP services, or a system like http://homebridge.io/).
Currently, Traefik is not creating the router and service associated to this "host" container, and print a logs like this:
It sounds legit as the Docker API reports an empty field for the IP Address:
There is a workaround, which is enabling the File provider, and creating the router + service manually, where the service points to the IP
172.17.0.1
, which is the default docker gateway, that points to the interfacedocker0
: if the backend container process listens on0.0.0.0
, then it can answer todocker0
upcoming requests as it is an host interface.One of the ideas would be having Traefik able to detect that case, and create Routers + Service , with the Service IP set to the gateway, so the configuration could still happen.
It looks like that https://github.com/containous/traefik/blob/v2.0/pkg/provider/docker/config.go#L257 means
127.0.0.1
should be returned. But this is not expected to work (unless Traefik container is ALSO run as network=host) as127.0.0.1
would be the loopback of the Traefik, which cannot route to the host interfaces asdocker0
.The text was updated successfully, but these errors were encountered: