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

swarm + macvlan + port publish mode=host is not working #2050

Open
blop opened this issue Jan 10, 2018 · 4 comments
Open

swarm + macvlan + port publish mode=host is not working #2050

blop opened this issue Jan 10, 2018 · 4 comments

Comments

@blop
Copy link

blop commented Jan 10, 2018

Trying to publish ports using the "host" mode on my swarm service, but it seems it's not supported when using a macvlan network driver.
We get logs like "macvlan driver does not support port mappings".

I need this to workaround this issue : moby/moby#25526

This is not working if "mynetwork" is macvlan based :
docker service create --network mynetwork --publish mode=host,target=80,published=80,protocol=tcp --name=web --mode=global nginx:alpine

@ddebroy
Copy link
Contributor

ddebroy commented Jan 10, 2018

In case of macvlan, the container IPs are directly accessible from outside the host (without having to go through NAT). So publishing ports in macvlan is not necessary and we report an error when you try to publish.

@blop
Copy link
Author

blop commented Jan 11, 2018

Indeed, the service ports are already accessible directly through it's IP inside the macvlan network.
However, in this case I'd like to have incoming connections from another network through a mapping on the host.
I understand it's not a popular use case but I don't see why Docker should not support it.

@blop
Copy link
Author

blop commented Apr 9, 2018

More details : this would be useful when you want high performance networking between your containers (by using macvlan on a dedicated network for clustering instead of the slower overlay network), and high performance ingest (by using a simple iptables rules that DNAT the traffic on each node the service is running instead of the slower standard swarm ingress), also working around moby/moby#25526.

For now I need to script the iptables DNAT rules creation outside of docker, with a lookup of the local container ip (which is dynamic).

Currently, as soon as the container is present in at least 1 macvlan network, no ports mapping is performed. Even if you put that container in multiple network and in the default network too.

@hufman
Copy link

hufman commented May 7, 2020

I encountered two variants of this problem (just using Docker Engine, not Swarm), I would be greatly appreciative if this could be resolved:

  1. I want to have a macvlan network to keep a collection of containers firewalled off, and use an Nginx Proxy attached to both the default and the macvlan networks to expose selected containers for access. As soon as I attach the macvlan network, the Nginx Proxy removes its published port on the default bridge and becomes inaccessible.

  2. Containers in the macvlan network, while they are indeed natively accessible, do not populate the published NetworkSettings.Ports map, which is required so that Nginx Proxy can find them and create links to them.

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