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

Fix traefik behavior when network_mode is host #5698

Merged
merged 9 commits into from Feb 11, 2020
Merged

Conversation

FuNK3Y
Copy link
Contributor

@FuNK3Y FuNK3Y commented Oct 21, 2019

What does this PR do?

When traefik cannot identify the ip address of the container, it returns 127.0.0.1 no matter what. This behavior is not desirable in many situations (i.e. exposed container running in network_mode = host while traefik doesn't, docker desktop, ...)

Motivation

It solves #5559 and #5535 and maybe a few other I didn't catch

Additional Notes

For this to work in linux, moby/moby#40007 needs to be merged. In the meantime you need to define "host.docker.internal" using extra_hosts if you want to take advantage of it.

In any case, this won't alter the current behavior. If you are running traefik in network_mode host or on a platform/version that does not provide the dns record its behavior won't change.

@FuNK3Y FuNK3Y changed the title Add redirect to host.docker.internal if network_mode=host Fix traefik behavior when network_mode is host Oct 21, 2019
@FuNK3Y
Copy link
Contributor Author

FuNK3Y commented Dec 23, 2019

Anything I can do to speed the merging of this one?

@FuNK3Y
Copy link
Contributor Author

FuNK3Y commented Jan 27, 2020

@ldez the underlying PR (moby/moby#40007) just got merged. Any idea when this one will get reviewed?

@ldez ldez self-requested a review January 27, 2020 21:51
@ldez ldez added this to To review in v2 via automation Feb 4, 2020
@juliens
Copy link
Member

juliens commented Feb 8, 2020

@FuNK3Y WDYT about my reword on the documentation?

Copy link
Contributor Author

@FuNK3Y FuNK3Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. You might keep the docker desktop part ouf of it; in my initial PR I mentioned it, but it turns out that host mode is not supported:
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server. (https://docs.docker.com/network/host/)

@Gelmo

This comment has been minimized.

@ldez ldez added this to the next milestone Feb 10, 2020
Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

docs/content/providers/docker.md Outdated Show resolved Hide resolved
FuNK3Y and others added 9 commits February 11, 2020 10:32
Added a few info about host networking
Remove new line
Replaced token by default IP address, as the feature is not yet released
Remove reference to docker desktop
@traefiker traefiker merged commit 0c90f6a into traefik:master Feb 11, 2020
v2 automation moved this from To review to Done Feb 11, 2020
@bjeanes
Copy link
Contributor

bjeanes commented May 3, 2020

It's worth noting that this broke a unit test which is still broken on master, but possibly only on hosts with host.docker.internal resolveable.

--- FAIL: TestDockerGetIPAddress (0.00s)
    --- FAIL: TestDockerGetIPAddress/two_networks,_no_network_label,_mode_host (0.00s)
        config_test.go:3256:
                Error Trace:    config_test.go:3256
                Error:          Not equal:
                                expected: "127.0.0.1"
                                actual  : "10.144.231.49"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -127.0.0.1
                                +10.144.231.49
                Test:           TestDockerGetIPAddress/two_networks,_no_network_label,_mode_host
    --- FAIL: TestDockerGetIPAddress/no_network,_no_network_label,_mode_host (0.00s)
        config_test.go:3256:
                Error Trace:    config_test.go:3256
                Error:          Not equal:
                                expected: "127.0.0.1"
                                actual  : "10.144.231.49"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -127.0.0.1
                                +10.144.231.49
                Test:           TestDockerGetIPAddress/no_network,_no_network_label,_mode_host

@akvadrako

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
v2
Done
Development

Successfully merging this pull request may close these issues.

None yet

8 participants