From 3c9dff2f758f7f18f0af4f327b7407f9923af53b Mon Sep 17 00:00:00 2001 From: sandyskies Date: Sun, 6 Mar 2016 20:29:23 +0800 Subject: [PATCH] add --network option for docker build Signed-off-by: sandyskies Signed-off-by: Tonis Tiigi --- command/image/build.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/command/image/build.go b/command/image/build.go index 19fd4aa709..7db76a649f 100644 --- a/command/image/build.go +++ b/command/image/build.go @@ -58,6 +58,7 @@ type buildOptions struct { cacheFrom []string compress bool securityOpt []string + networkMode string } // NewBuildCommand creates a new `docker build` command @@ -105,6 +106,7 @@ func NewBuildCommand(dockerCli *command.DockerCli) *cobra.Command { flags.StringSliceVar(&options.cacheFrom, "cache-from", []string{}, "Images to consider as cache sources") flags.BoolVar(&options.compress, "compress", false, "Compress the build context using gzip") flags.StringSliceVar(&options.securityOpt, "security-opt", []string{}, "Security options") + flags.StringVar(&options.networkMode, "network", "default", "Connect a container to a network") command.AddTrustedFlags(flags, true) @@ -302,6 +304,7 @@ func runBuild(dockerCli *command.DockerCli, options buildOptions) error { Labels: runconfigopts.ConvertKVStringsToMap(options.labels.GetAll()), CacheFrom: options.cacheFrom, SecurityOpt: options.securityOpt, + NetworkMode: options.networkMode, } response, err := dockerCli.Client().ImageBuild(ctx, body, buildOptions)