summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-03-22 09:51:10 +0100
committerJoffrey F <joffrey@docker.com>2018-03-22 14:07:18 +0100
commit77c977bce75d028d03dbde85ede053a1dddc017e (patch)
tree3d918d095ec029618752fdaa73794c8c1de2ff9f
parent7a28cad58ec7c279b91c75a3aa701bb89e0e75cd (diff)
downloaddocker-py-build_isolation.tar.gz
Add isolation param to buildbuild_isolation
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/build.py11
-rw-r--r--docker/models/images.py2
-rw-r--r--tests/integration/api_build_test.py15
3 files changed, 27 insertions, 1 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index e136a6e..3067c10 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -18,7 +18,7 @@ class BuildApiMixin(object):
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
- squash=None, extra_hosts=None, platform=None):
+ squash=None, extra_hosts=None, platform=None, isolation=None):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
@@ -100,6 +100,8 @@ class BuildApiMixin(object):
extra_hosts (dict): Extra hosts to add to /etc/hosts in building
containers, as a mapping of hostname to IP address.
platform (str): Platform in the format ``os[/arch[/variant]]``
+ isolation (str): Isolation technology used during build.
+ Default: `None`.
Returns:
A generator for the build output.
@@ -232,6 +234,13 @@ class BuildApiMixin(object):
)
params['platform'] = platform
+ if isolation is not None:
+ if utils.version_lt(self._version, '1.24'):
+ raise errors.InvalidVersion(
+ 'isolation was only introduced in API version 1.24'
+ )
+ params['isolation'] = isolation
+
if context is not None:
headers = {'Content-Type': 'application/tar'}
if encoding:
diff --git a/docker/models/images.py b/docker/models/images.py
index d4c2813..bb24eb5 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -164,6 +164,8 @@ class ImageCollection(Collection):
extra_hosts (dict): Extra hosts to add to /etc/hosts in building
containers, as a mapping of hostname to IP address.
platform (str): Platform in the format ``os[/arch[/variant]]``.
+ isolation (str): Isolation technology used during build.
+ Default: `None`.
Returns:
(tuple): The first item is the :py:class:`Image` object for the
diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py
index ce587d5..13bd8ac 100644
--- a/tests/integration/api_build_test.py
+++ b/tests/integration/api_build_test.py
@@ -138,6 +138,21 @@ class BuildTest(BaseAPIIntegrationTest):
# There is currently no way to get the shmsize
# that was used to build the image
+ @requires_api_version('1.24')
+ def test_build_isolation(self):
+ script = io.BytesIO('\n'.join([
+ 'FROM scratch',
+ 'CMD sh -c "echo \'Deaf To All But The Song\''
+ ]).encode('ascii'))
+
+ stream = self.client.build(
+ fileobj=script, tag='isolation',
+ isolation='default'
+ )
+
+ for chunk in stream:
+ pass
+
@requires_api_version('1.23')
def test_build_labels(self):
script = io.BytesIO('\n'.join([