Skip to content

Commit 27322fe

Browse files
committed
Add isolation param to build
Signed-off-by: Joffrey F <[email protected]>
1 parent 73a9003 commit 27322fe

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

docker/api/build.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
1818
forcerm=False, dockerfile=None, container_limits=None,
1919
decode=False, buildargs=None, gzip=False, shmsize=None,
2020
labels=None, cache_from=None, target=None, network_mode=None,
21-
squash=None, extra_hosts=None, platform=None):
21+
squash=None, extra_hosts=None, platform=None, isolation=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
@@ -100,6 +100,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
100100
extra_hosts (dict): Extra hosts to add to /etc/hosts in building
101101
containers, as a mapping of hostname to IP address.
102102
platform (str): Platform in the format ``os[/arch[/variant]]``
103+
isolation (str): Isolation technology used during build.
104+
Default: `None`.
103105
104106
Returns:
105107
A generator for the build output.
@@ -232,6 +234,13 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
232234
)
233235
params['platform'] = platform
234236

237+
if isolation is not None:
238+
if utils.version_lt(self._version, '1.24'):
239+
raise errors.InvalidVersion(
240+
'isolation was only introduced in API version 1.24'
241+
)
242+
params['isolation'] = isolation
243+
235244
if context is not None:
236245
headers = {'Content-Type': 'application/tar'}
237246
if encoding:

docker/models/images.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def build(self, **kwargs):
164164
extra_hosts (dict): Extra hosts to add to /etc/hosts in building
165165
containers, as a mapping of hostname to IP address.
166166
platform (str): Platform in the format ``os[/arch[/variant]]``.
167+
isolation (str): Isolation technology used during build.
168+
Default: `None`.
167169
168170
Returns:
169171
(tuple): The first item is the :py:class:`Image` object for the

tests/integration/api_build_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ def test_build_shmsize(self):
138138
# There is currently no way to get the shmsize
139139
# that was used to build the image
140140

141+
@requires_api_version('1.24')
142+
def test_build_isolation(self):
143+
script = io.BytesIO('\n'.join([
144+
'FROM scratch',
145+
'CMD sh -c "echo \'Deaf To All But The Song\''
146+
]).encode('ascii'))
147+
148+
stream = self.client.build(
149+
fileobj=script, tag='isolation',
150+
isolation='default'
151+
)
152+
153+
for chunk in stream:
154+
pass
155+
141156
@requires_api_version('1.23')
142157
def test_build_labels(self):
143158
script = io.BytesIO('\n'.join([

0 commit comments

Comments
 (0)