summaryrefslogtreecommitdiff
path: root/docker/api
diff options
context:
space:
mode:
Diffstat (limited to 'docker/api')
-rw-r--r--docker/api/build.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index f30be41..cbef4a8 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -18,7 +18,7 @@ class BuildApiMixin(object):
custom_context=False, encoding=None, pull=False,
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
- labels=None, cache_from=None, target=None):
+ labels=None, cache_from=None, target=None, network_mode=None):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
@@ -88,14 +88,16 @@ class BuildApiMixin(object):
- cpusetcpus (str): CPUs in which to allow execution, e.g.,
``"0-3"``, ``"0,1"``
decode (bool): If set to ``True``, the returned stream will be
- decoded into dicts on the fly. Default ``False``.
+ decoded into dicts on the fly. Default ``False``
shmsize (int): Size of `/dev/shm` in bytes. The size must be
- greater than 0. If omitted the system uses 64MB.
- labels (dict): A dictionary of labels to set on the image.
+ greater than 0. If omitted the system uses 64MB
+ labels (dict): A dictionary of labels to set on the image
cache_from (list): A list of images used for build cache
- resolution.
+ resolution
target (str): Name of the build-stage to build in a multi-stage
- Dockerfile.
+ Dockerfile
+ network_mode (str): networking mode for the run commands during
+ build
Returns:
A generator for the build output.
@@ -208,6 +210,14 @@ class BuildApiMixin(object):
'target was only introduced in API version 1.29'
)
+ if network_mode:
+ if utils.version_gte(self._version, '1.25'):
+ params.update({'networkmode': network_mode})
+ else:
+ raise errors.InvalidVersion(
+ 'network_mode was only introduced in API version 1.25'
+ )
+
if context is not None:
headers = {'Content-Type': 'application/tar'}
if encoding: