@@ -18,7 +18,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
1818 custom_context = False , encoding = None , pull = False ,
1919 forcerm = False , dockerfile = None , container_limits = None ,
2020 decode = False , buildargs = None , gzip = False , shmsize = None ,
21- labels = None , cache_from = None , target = None ):
21+ labels = None , cache_from = None , target = None , network_mode = None ):
2222 """
2323 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
2424 needs to be set. ``path`` can be a local path (to a directory
@@ -88,14 +88,16 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
8888 - cpusetcpus (str): CPUs in which to allow execution, e.g.,
8989 ``"0-3"``, ``"0,1"``
9090 decode (bool): If set to ``True``, the returned stream will be
91- decoded into dicts on the fly. Default ``False``.
91+ decoded into dicts on the fly. Default ``False``
9292 shmsize (int): Size of `/dev/shm` in bytes. The size must be
93- greater than 0. If omitted the system uses 64MB.
94- labels (dict): A dictionary of labels to set on the image.
93+ greater than 0. If omitted the system uses 64MB
94+ labels (dict): A dictionary of labels to set on the image
9595 cache_from (list): A list of images used for build cache
96- resolution.
96+ resolution
9797 target (str): Name of the build-stage to build in a multi-stage
98- Dockerfile.
98+ Dockerfile
99+ network_mode (str): networking mode for the run commands during
100+ build
99101
100102 Returns:
101103 A generator for the build output.
@@ -208,6 +210,14 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
208210 'target was only introduced in API version 1.29'
209211 )
210212
213+ if network_mode :
214+ if utils .version_gte (self ._version , '1.25' ):
215+ params .update ({'networkmode' : network_mode })
216+ else :
217+ raise errors .InvalidVersion (
218+ 'network_mode was only introduced in API version 1.25'
219+ )
220+
211221 if context is not None :
212222 headers = {'Content-Type' : 'application/tar' }
213223 if encoding :
0 commit comments