@@ -18,7 +18,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
18
18
custom_context = False , encoding = None , pull = False ,
19
19
forcerm = False , dockerfile = None , container_limits = None ,
20
20
decode = False , buildargs = None , gzip = False , shmsize = None ,
21
- labels = None , cache_from = None , target = None , network_mode = None ):
21
+ labels = None , cache_from = None , target = None , network_mode = None ,
22
+ squash = None ):
22
23
"""
23
24
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
24
25
needs to be set. ``path`` can be a local path (to a directory
@@ -98,6 +99,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
98
99
Dockerfile
99
100
network_mode (str): networking mode for the run commands during
100
101
build
102
+ squash (bool): Squash the resulting images layers into a
103
+ single layer.
101
104
102
105
Returns:
103
106
A generator for the build output.
@@ -218,6 +221,14 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
218
221
'network_mode was only introduced in API version 1.25'
219
222
)
220
223
224
+ if squash :
225
+ if utils .version_gte (self ._version , '1.25' ):
226
+ params .update ({'squash' : squash })
227
+ else :
228
+ raise errors .InvalidVersion (
229
+ 'squash was only introduced in API version 1.25'
230
+ )
231
+
221
232
if context is not None :
222
233
headers = {'Content-Type' : 'application/tar' }
223
234
if encoding :
0 commit comments