build: handle --network

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass
2019-04-17 03:48:38 +00:00
parent 77ed999572
commit 635e393ae5
2 changed files with 13 additions and 7 deletions

View File

@@ -37,6 +37,7 @@ type Options struct {
Pull bool
ImageIDFile string
ExtraHosts []string
NetworkMode string
NoCache bool
Target string
@@ -228,6 +229,14 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, pw
so.FrontendAttrs["platform"] = strings.Join(pp, ",")
}
switch opt.NetworkMode {
case "host", "none":
so.FrontendAttrs["force-network-mode"] = opt.NetworkMode
case "", "default":
default:
return nil, errors.Errorf("network mode %q not supported by buildkit", opt.NetworkMode)
}
extraHosts, err := toBuildkitExtraHosts(opt.ExtraHosts)
if err != nil {
return nil, err