@@ -275,32 +275,38 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
275
275
return self ._stream_helper (response , decode = decode )
276
276
277
277
@utils .minimum_version ('1.31' )
278
- def prune_builds (self , filters = None , keep_storage = None , all = None ):
278
+ def prune_builds (self , filters = None , keep_storage = None , all = None , max_used_space = None , reserved_space = None , min_free_space = None ):
279
279
"""
280
- Delete the builder cache
281
-
282
- Args:
283
- filters (dict): Filters to process on the prune list.
284
- Needs Docker API v1.39+
285
- Available filters:
286
- - dangling (bool): When set to true (or 1), prune only
287
- unused and untagged images.
288
- - until (str): Can be Unix timestamps, date formatted
289
- timestamps, or Go duration strings (e.g. 10m, 1h30m) computed
290
- relative to the daemon's local time.
291
- keep_storage (int): Amount of disk space in bytes to keep for cache.
292
- Needs Docker API v1.39+
293
- all (bool): Remove all types of build cache.
294
- Needs Docker API v1.39+
295
-
296
- Returns:
297
- (dict): A dictionary containing information about the operation's
298
- result. The ``SpaceReclaimed`` key indicates the amount of
299
- bytes of disk space reclaimed.
300
-
301
- Raises:
302
- :py:class:`docker.errors.APIError`
303
- If the server returns an error.
280
+ Delete the builder cache
281
+
282
+ Args:
283
+ filters (dict): Filters to process on the prune list.
284
+ Needs Docker API v1.39+
285
+ Available filters:
286
+ - dangling (bool): When set to true (or 1), prune only
287
+ unused and untagged images.
288
+ - until (str): Can be Unix timestamps, date formatted
289
+ timestamps, or Go duration strings (e.g. 10m, 1h30m) computed
290
+ relative to the daemon's local time.
291
+ keep_storage (int): Amount of disk space in bytes to keep for cache.
292
+ Needs Docker API v1.39+
293
+ all (bool): Remove all types of build cache.
294
+ Needs Docker API v1.39+
295
+ reserved-space (int): The minimum amount of disk space that Docker is allowed to keep for build cache.
296
+ Cache below this threshold won't be removed during garbage collection.
297
+ max-used-space (int): The maximum amount of disk space that Docker is allowed to use for build cache.
298
+ Any usage above this threshold will be reclaimed during garbage collection. Needs Docker API v1.48+
299
+ min-free-space (int): The target amount of free disk space that the garbage collector will attempt to maintain on your system.
300
+ Needs Docker API v1.48+
301
+
302
+ Returns:
303
+ (dict): A dictionary containing information about the operation's
304
+ result. The ``SpaceReclaimed`` key indicates the amount of
305
+ bytes of disk space reclaimed.
306
+
307
+ Raises:
308
+ :py:class:`docker.errors.APIError`
309
+ If the server returns an error.
304
310
"""
305
311
url = self ._url ("/build/prune" )
306
312
if (filters , keep_storage , all ) != (None , None , None ) \
@@ -316,6 +322,12 @@ def prune_builds(self, filters=None, keep_storage=None, all=None):
316
322
params ['keep-storage' ] = keep_storage
317
323
if all is not None :
318
324
params ['all' ] = all
325
+ if max_used_space is not None :
326
+ params ['max-used-space' ] = max_used_space
327
+ if reserved_space is not None :
328
+ params ['reserved-space' ] = reserved_space
329
+ if min_free_space is not None :
330
+ params ['min-free-space' ] = min_free_space
319
331
return self ._result (self ._post (url , params = params ), True )
320
332
321
333
def _set_auth_headers (self , headers ):
0 commit comments