-
Notifications
You must be signed in to change notification settings - Fork 18.9k
add --net options for docker build . #20987
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
Conversation
Signed-off-by: sandyskies <chenmingjie0828@163.com>
|
Initially I had some hesitation here (still not 100% sold), but I think this should be ok. The portability of the build itself is probably still fine as people can rely on the same kind of functionality that networks provide (DNS discovery) even without this change. -- EDIT -- |
|
Thanks @sandyskies! Following the discussion on #10324 I'm not sure we should implement this though; there's quite some concerns around adding this option, but let's wait for other maintainers to comment here as well edit: just see @cpuguy83 commented already (sorry GitHub didn't show his comment yet) |
|
I think --net=host options is what most guys want most as we can see in the issue mentioned about. In some occasion, bridge network mode is not allowed because of security reason and lack of ip resource. So if some guys want to build a image from a Dockerfile in this particular occasion, he just can't connect to network, which makes him unable use apt-get or yum command to manager software. |
Signed-off-by: sandyskies <chenmingjie0828@163.com>
| } | ||
|
|
||
| query.Set("cpusetcpus", options.CPUSetCPUs) | ||
| query.Set("netmode", options.NetMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these changes go in https://github.com/docker/engine-api. Then, we need to revendor the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I create a PR for https://github.com/docker/engine-api first? @calavera
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandyskies Yes, create a PR in https://github.com/docker/engine-api :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have create the PR ( 159 ). @calavera @coolljt0725
|
ping @tiborvass @calavera could you have a look at this please? what are your thoughts? |
|
It is impossible to install uhd-host Ubuntu package during "docker build" as there are missing files that are required by it (/proc/sys/net/core/rmem_max and /proc/sys/net/core/wmem_max). These files are created by --net=host option when calling docker run. |
|
@ptrkrysik Can this PR fix ur problem or not? |
|
I messed this PR with issue that there is no --net=host during 'docker build'. The discussion here seemed much more fruitful than in #10324 (which messes two separate issues). Sorry for confusion. I haven't yet checked if this PR is what is needed to fix issue with installation of uhd-host package. |
|
We just discussed this PR in our maintainers review session, and would like to look into the use-cases in #10324 to see if this is the best solution, or if there are other solutions that may be better. @justincormack is going to have a look at those, and @vdemeester has some alternative approaches that may be worth investigating. |
|
There seem to be a bunch of reasons for this feature request mainly discussed in #10324, will try to summarise:
Overall I think that adding features to support what are essentially not properly working docker installs that do not have working network isolation, is probably a mistake, as there does not seem to be any justifiable use case on working docker install, so I have to recommend that we do not go ahead with this PR. |
|
@justincormack Ur summarise doesn't include my use case. The commany I work for has a strict security policy ,iptable_nat is not allowed to use in production environment, and we are not allow to allocate ip freely. Therefor bridge network mode is not a option in our production environment, host network mode is the only one choice(We consider performance as well) . Without this pr, there is no way I can use networking When build a image from Dockerfile. I think many people have the same use case as I do, include cloud vm u mentioned in number 2( I don't agree about that u think this is not a common issue. Cloud providers providing a guest os that bridge network mode won't work should be common issue.) |
|
@sandyskies It is not really recommended that you do builds on your production servers, you should be aiming to do them in your CI pipelines. I don't think there is any security reason why your CI machines should not use NAT in general, even if production is restricted like that. Can you give me an example of a cloud provider guest image that does not work with bridged networking? Note that you should be able to use bridged networking without NAT as well if you allocate routed IP addresses to the bridge (ipv4 or ipv6). |
|
@justincormack As I mentioned , routed IP addresses could not be allocated freely in my company. In #10324 michaeljoy mentioned that: I don't think this is just a coincidence. |
|
@justincormack Another use case: Users who build images with dependencies on private rubygems servers and/or npm repositories, and where they are hosting said repositories inside docker. Workarounds include passing IP addresses to |
|
@rkuzsma that's not a use case that we want to support; building a Dockerfile should be reproducible, and requiring other containers or services to be started in order to build the Dockerfile make them non-reproducible, unless you're in exactly the same setup, so not something we want to support. |
|
Unless I'm mistaken (and I'm hardly an expert in Docker so I may very well be), you can already induce the unreproducible build situation. The On the other hand, we also have unreproducible builds by not being able to access any network content. Essentially no images can be built when connected with a Cisco VPN client. Fetching something from localhost is bad, sure. But that's a policy/cultural/people problem that's easily solvable with communication. Not being able to use |
|
The absence of this option is creating unreproduceable builds for many Gonçalo Luiz On 23 June 2016 at 19:24, Jess Frazelle notifications@github.com wrote:
|
|
I am agree with @gedl . The absence of --net host may cause much more unportable builds. People use the same Dockerfile ,and they are under different environment, one can connect to network and one are unable to because without this option. Do u think they can build the exact same image from that Dockerfile ? @jfrazelle |
|
Wanted to chime in and say that the lack of |
|
@crosbymichael If the user has VPN enabled it will hijack the main routing table so bridge network which also needs routing may be affected. There is nothing we can do there as this is really the security policy in VPN which in most deployments disables "split tunneling" mode. As far as users having issues with cloud providers we should try to understand what they are. Because there shouldn't be any and if there is any that should be fixed first because that probably affects |
|
@dend Can you explain what issues you are having in an Azure VM when doing a |
|
@mrjana But, Docker already has a solution for this for "docker run". This PR is about extending that same functionality to "docker build", which would address the issue. |
|
@mrjana I have a Stack Overflow question that documents my case. |
|
I also bump into this limitation today. As others pointed out, I don't see how this feature makes building less reproducible considering that network traffic that is already allowed during a |
|
+1 I badly need this. |
|
Hi @sandyskies we are reconsidering this - would you like to rebase it and we can look at reviewing and merging it. |
|
I extended this in master...tonistiigi:net-builder to add builder directives for The values are comma separated list of keys. Negation is supported with Let me know if this seems reasonable compromise and I'll add more integration tests. |
|
@tonistiigi that seems like it could be useful in some cases. |
|
Shouldn't the option be called Or does this ( |
|
ping @sandyskies could you have a look at @tonistiigi's comment? #20987 (comment) |
| flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)") | ||
| flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)") | ||
| flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container") | ||
| flNetMode := cmd.String([]string{"-net"}, "default", "Connect a container to a network") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the option to --network to match docker run. Apparently it changed over there in June: c0c7d5e
|
This is being carried in #27702, so I'll close this PR |
|
@thaJeztah sorry ,it takes a long time in design-review, as someone else has make the another pull |
|
@sandyskies no worries! your commit is preserved in #27702, thanks so much for starting the work on this |
fixed 10324
docker could't point a network mode when build a image ,in my case, we are unable to use bridge network mode because my company's restriction. So when I building a docker image , I could't connect to network in container, which is quite annoying.
So I add --net options for docker build command to use host network mode.
To verify this feature, create Dockerfile like following:
then run:
to get the output the make sure use the correct mode
Signed-off-by: sandyskies chenmingjie0828@163.com