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

Add a network namespace driver to libnetwork #372

Closed
wants to merge 1 commit into from

Conversation

alecbenson
Copy link
Contributor

This driver allows containers to run in a pre-defined network namespace (can be created via "ip netns add __", for example). It works by simply creating a symbolic link between the network namespace in /var/run/docker/netns/{id} and the provided network namespace.

This patch provides very similar functionality to the patch proposed here:
moby/moby#8216

However, this patch integrates into libnetwork and better conforms with Docker's "batteries included but removable" design goals. The namespace driver included in this PR offers Docker users much greater flexibility when deploying containers and removes the need for unsupported third party tools that attempt to achieve similar functionality.

Signed-off-by: Alec Benson albenson@redhat.com

…tainers to run in a pre-defined network namespace. It works by simply creating a symlink between the network namespace in /var/run/docker/netns and the provided network namespace.

Signed-off-by: Alec Benson <albenson@redhat.com>
@dave-tucker
Copy link
Contributor

Hi @alecbenson thanks for your contribution. I've tagged this one for design review and hopefully one of the maintainers will be able to take a look and give you some feedback.

I'm 👎 to this right now. The landscape has changed since moby/moby#8216 was raised - we now have a plugin framework and an ecosystem of network plugins. What use cases are we trying to address here that cannot be satisfied with network plugins?

Additionally, it would seem that this patch is actually changing the SandboxAPI (in this case, NewSandbox). That makes me a little uncomfortable. I'm not yet sure (I've only scanned the code) whether this will have an effect on plugins and whether libnetwork is still in control of the Sandbox lifecycle or not.

One last point, the UI that you have in the docs doesn't map with what's being proposed in moby/moby#14593 - which is either --net=NETWORK or --net=network:NETWORK.

The driver called by libnetwork is selected based on the network that a container is supposed to be connected to (iirc). I would think that in this case you would need to create one "network" backed by the "namespace" driver for each container, passing the path of the pre-created netns as a label on network creation.

docker network create netns12345 -l namespace.path=/var/run/netns/12345
docker run -itd --net=netns12345 fedora

Note: The contract of a network implies that all containers in a network can communicate freely which is why I'm recommending a network per netns

@mavenugo
Copy link
Contributor

Agreed with @dave-tucker.
This PR breaks the basis of libnetwork's CNM model and breaks the sandbox abstraction.
👎 from me as well.

@rhatdan
Copy link

rhatdan commented Jul 23, 2015

@dave-tucker I like the idea of

docker network create netns12345 -l namespace.path=/var/run/netns/12345
docker run -itd --net=netns12345 fedora

Which would also satisfy our needs, but how close is this to reality?

@dave-tucker
Copy link
Contributor

@rhatdan I'm not sure. I'll defer to @mavenugo as his point re: the CNM abstractions is a good one.

It might help if we understood the use case better, and why the CNM isn't a good fit and why whatever it is that you need can't be satisfied by a driver/plugin.

@rhatdan
Copy link

rhatdan commented Jul 23, 2015

All we want is the ability to create a network namespace on the host and then be able to use it within a container.

@mavenugo
Copy link
Contributor

mavenugo commented Aug 4, 2015

@rhatdan @alecbenson I certainly understand the intent of the PR and I do see how this is beneficial for some use-cases. But, this is not in the spirit of the CNM Model, where the namespace is a black box for the drivers and that lets libnetwork core to provide a consistent experience to the applications using llibnetwork. Also, it impacts the upcoming changes that are related to User namespace support.
Having said that, Libnetwork drivers can be implemented as external plugins and any driver that implements and adheres to the Driver API can absolutely have an implementation of choice.
Also please note that this area of the code is undergoing some changes for user namespace support. Please look out for it and it might be of some interest to you.

@rhatdan
Copy link

rhatdan commented Aug 4, 2015

@mavenugo How do you implement changes in the docker cli to use a network plugin? Is this possible?

@mavenugo
Copy link
Contributor

mavenugo commented Aug 4, 2015

@rhatdan yes. It is currently available on the docker experimental channel. please refer to https://github.com/docker/docker/blob/master/experimental/networking.md.
Based on various feedback, we are soliciting inputs to change the UI slightly. But fundamentals will remain the same.

@alecbenson
Copy link
Contributor Author

@mavenugo Thanks for the info. If I am understanding you correctly, you are saying is that the network namespace should be out of the scope of the driver? If that is the case, is there any way we can get this functionality using the plugin system that you linked? It is possible that I am mistaken -- but it seems that in any case, we would need to modify NewSandbox to prevent it from creating a network namespace and that cannot be done solely within the confinment of the driver.

@mavenugo
Copy link
Contributor

mavenugo commented Aug 5, 2015

@alecbenson your understanding is correct.
But as I explained, this area of the code is going through some changes for the user namespace support and hence it is hard for me to give an implementation level answer. But the design stands & we should try and honor the driver APIs to the level of providing network resources which the core applies on the namespace that it manages.
I my previous comment, I meant to say that the driver can implement the network resource allocation in whichever way it seems fit. I didnt mean to say that the driver should be managing the namespace fully outside the libnetwork's management. That is the fundamental issue with this PR.

@mavenugo
Copy link
Contributor

closing the issue based on the above explanation. feel free to reopen it if you still think this needs attention.

@mavenugo mavenugo closed this Sep 10, 2015
@rhatdan
Copy link

rhatdan commented Sep 10, 2015

Going back and reasing your answer to Alec back in August.

Are you saying that the Plugin api will never support the use of external namespaces? IE Namespaces created outside of docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants