-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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 "--network-opt" option as a way to pass arbitrary options to network drivers #27638
Conversation
@axqx thanks for the PR. am generally 👍 for providing such flexibility for users to make use of the driver capabilities. I initially tried to get this via labels (#13476), but was not accepted for good reason. If we have an explicit option (I will change it to |
@mavenugo, thank you for your feedback. I added the change you suggested (--net-opt to --network-opt) in commit 4a5768604535a867d16c8509970eece1e6b42a6d. |
@axqx don't forget to update the API changes; docs/reference/api/docker_remote_api.md#v125-api-changes, and the networks section in the API reference itself docs/reference/api/docker_remote_api_v1.25.md#35-networks |
Thank you @thaJeztah. The API documentation is now updated in commit d24405599bb314da4de3c3a509bc7d607e463c24 |
@axqx while we are at this, shall we expand this a little more to make it more effective ?
@icecrime @mrjana given we have multiple requests for such a support and we couldn't get #13476 in ... can you share your views on adding such an option ? |
@mavenugo Don't you think that we should make this PR as atomic as possible to avoid blocking forward progress ? |
@mavenugo Seems fine by me, I'm happy as long as we're not using labels as the vehicle for arbitrary driver-specific options. A couple things that we maybe need to look into:
|
@axqx @jc-m yes. agreed. We can move the |
@icecrime thanks for the confirmation.
These options are directly related to CNM objects of Network and Endpoint. Driver option for network goes via
Good question. Is there such a requirement ? @cpuguy83 |
@axqx also, this should address the |
Volumes have parity via |
+1 on adding these options to |
@mauri it is not unrelated. They are closely related concepts with different hook points. A good example of this is the |
@mavenugo Playing devil's advocate here:
Is it |
😄 True. But the user really don't need to worry about that. Since this is a per-container option for that "network", |
Fair enough 😉 I think it makes sense when properly explained: this configures driver-specific options for attaching that particular container to the network. Design LGTM 👍 |
@mavenugo , thanks for pointing out the docker network connect use-case, indeed it needs to be addressed here. Regarding the --ipam-opt, it is certainly a related feature but implementation wise is independent from this change, so I really think it belongs to a different PR. I believe that separating independent functionality into different PRs allows to progress faster towards successfully integrating new features. |
@m-kostrzewa @axqx apologies on expanding the scope of this PR. We are between rock and hard place here. We recognize that the option is useful for network drivers. But we have made mistakes with the UX/API in the past which makes it hard to provide any reasonable compatibility. So as @thaJeztah suggested, I think it is better to start investing on the advanced |
7cbcd2a
to
3552b6e
Compare
@vdemeester, @mavenugo, @thaJeztah, added some integration tests and will work on the advanced --network syntax next. |
Thanks @axqx - let me put this PR back in "design review" pending those changes 👍 |
1aa2cdb
to
3c73ccd
Compare
2266279
to
95b3831
Compare
…o network drivers - Fixes moby#910 The docker plugin model has made it easier to extend docker with custom drivers that can be maintained independently by third parties. However, as reported by issue moby/libnetwork#910 a way of passing arbitrary parameters from docker client to remote driver is needed. Many use cases require passing network configuration to a network driver that might vary from container to container and might only be known at container creation time. Examples are configuring the MTU or queue length of a network interface or passing ip aliases, routes or iptables rules for containers. This patch proposes adding a new --net-opt option to docker to allow passing arbitrary information to network drivers. net-opt options are used with docker run command and are directly copied to the container's NetworkSettings and then passed to the network driver on endpoint create. Signed-off-by: Alina Quereilhac <alina@medallia.com>
… and ipam driver options Syntax example: docker run --network "name=network-name,key1=val1,key2=val2" \ --ipam "name=network-name,key1=val1,key2=val2" --ip 10.1.0.2 alpine sh Signed-off-by: Alina Quereilhac <alina@medallia.com>
@mavenugo, @aboch, @sanimej, @thaJeztah, the PR is now updated with the advanced --network/ipam syntax for docker run. Could you please take a look at the changes? Some usage examples:
|
Hi, are you planning include this feature in the next release? It's very useful for custom driver. Today we should create many different networks to be hable to configure different ipam options on a custom driver. |
@axqx thanks for your effort on this.
This doesn't capture the requirement well. Since there are many more network specific options other than name and driver opts. PTAL #31964 for an idea of what the proposal will look like. Ofcourse for this PR, you are worried only about |
@mavenugo good question, IIUC, changes will all be in the CLI/client, so could be realistic to get it in if a maintainer or contributor is able to reserve some time to implement it. |
docker supports alternate OCI runtimes including virtual machine based runtimes. In certian cases network plugins can optionally choose to support creation of virtual machine friendly interfaces using optional network options. This is illustrated here with the hint being used by the macvlan driver to create a macvtap interface vs a macvlan interface when the runtime is known to be a VM based runtime. docker run --runtime=cor -it --net=pub_net --network "name=pub_net,runtime=namespace" alpine sh This is currently based off of moby/moby#27638 However this will be implemented as per the proposal moby/moby#31964 Signed-off-by: Manohar Castelino <manohar.r.castelino@intel.com>
@thaJeztah, thanks for the update. Unfortunately I don't have time now to work on #31964, so I will wait until a stable form of the --network flag is achieved before resuming work on passing network options to drivers. |
The docker plugin model has made it easier to extend docker with custom
drivers that can be maintained independently by third parties. However,
as reported by issue Passing arbitrary parameters/labels to a remote driver libnetwork#910
a way of passing arbitrary parameters from docker client to remote
driver is needed.
Many use cases require passing network configuration to a network driver
that might vary from container to container and might only be known at
container creation time. Examples are configuring the MTU or queue
length of a network interface or passing ip aliases, routes or iptables
rules for containers. This patch proposes adding a new --net-opt option
to docker to allow passing arbitrary information to network drivers.
net-opt options are used with docker run command and are directly copied
to the container's NetworkSettings and then passed to the network driver
on endpoint create.
Signed-off-by: Alina Quereilhac alina@medallia.com