@@ -108,7 +108,7 @@ def commit(self, container, repository=None, tag=None, message=None,
108
108
author (str): The name of the author
109
109
changes (str): Dockerfile instructions to apply while committing
110
110
conf (dict): The configuration for the container. See the
111
- `Remote API documentation
111
+ `Engine API documentation
112
112
<https://docs.docker.com/reference/api/docker_remote_api/>`_
113
113
for full details.
114
114
@@ -238,7 +238,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
238
238
memswap_limit = None , cpuset = None , host_config = None ,
239
239
mac_address = None , labels = None , volume_driver = None ,
240
240
stop_signal = None , networking_config = None ,
241
- healthcheck = None ):
241
+ healthcheck = None , stop_timeout = None ):
242
242
"""
243
243
Creates a container. Parameters are similar to those for the ``docker
244
244
run`` command except it doesn't support the attach options (``-a``).
@@ -313,9 +313,10 @@ def create_container(self, image, command=None, hostname=None, user=None,
313
313
314
314
**Using volumes**
315
315
316
- Volume declaration is done in two parts. Provide a list of mountpoints
317
- to the with the ``volumes`` parameter, and declare mappings in the
318
- ``host_config`` section.
316
+ Volume declaration is done in two parts. Provide a list of
317
+ paths to use as mountpoints inside the container with the
318
+ ``volumes`` parameter, and declare mappings from paths on the host
319
+ in the ``host_config`` section.
319
320
320
321
.. code-block:: python
321
322
@@ -392,7 +393,8 @@ def create_container(self, image, command=None, hostname=None, user=None,
392
393
version 1.10. Use ``host_config`` instead.
393
394
dns_opt (:py:class:`list`): Additional options to be added to the
394
395
container's ``resolv.conf`` file
395
- volumes (str or list):
396
+ volumes (str or list): List of paths inside the container to use
397
+ as volumes.
396
398
volumes_from (:py:class:`list`): List of container names or Ids to
397
399
get volumes from.
398
400
network_disabled (bool): Disable networking
@@ -411,6 +413,8 @@ def create_container(self, image, command=None, hostname=None, user=None,
411
413
volume_driver (str): The name of a volume driver/plugin.
412
414
stop_signal (str): The stop signal to use to stop the container
413
415
(e.g. ``SIGINT``).
416
+ stop_timeout (int): Timeout to stop the container, in seconds.
417
+ Default: 10
414
418
networking_config (dict): A networking configuration generated
415
419
by :py:meth:`create_networking_config`.
416
420
@@ -437,6 +441,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
437
441
network_disabled , entrypoint , cpu_shares , working_dir , domainname ,
438
442
memswap_limit , cpuset , host_config , mac_address , labels ,
439
443
volume_driver , stop_signal , networking_config , healthcheck ,
444
+ stop_timeout
440
445
)
441
446
return self .create_container_from_config (config , name )
442
447
@@ -457,6 +462,8 @@ def create_host_config(self, *args, **kwargs):
457
462
:py:meth:`create_container`.
458
463
459
464
Args:
465
+ auto_remove (bool): enable auto-removal of the container on daemon
466
+ side when the container's process exits.
460
467
binds (dict): Volumes to bind. See :py:meth:`create_container`
461
468
for more information.
462
469
blkio_weight_device: Block IO weight (relative device weight) in
@@ -542,6 +549,8 @@ def create_host_config(self, *args, **kwargs):
542
549
security_opt (:py:class:`list`): A list of string values to
543
550
customize labels for MLS systems, such as SELinux.
544
551
shm_size (str or int): Size of /dev/shm (e.g. ``1G``).
552
+ storage_opt (dict): Storage driver options per container as a
553
+ key-value mapping.
545
554
sysctls (dict): Kernel parameters to set in the container.
546
555
tmpfs (dict): Temporary filesystems to mount, as a dictionary
547
556
mapping a path inside the container to options for that path.
@@ -906,16 +915,35 @@ def put_archive(self, container, path, data):
906
915
Raises:
907
916
:py:class:`docker.errors.APIError`
908
917
If the server returns an error.
909
-
910
- Raises:
911
- :py:class:`~docker.errors.APIError` If an error occurs.
912
918
"""
913
919
params = {'path' : path }
914
920
url = self ._url ('/containers/{0}/archive' , container )
915
921
res = self ._put (url , params = params , data = data )
916
922
self ._raise_for_status (res )
917
923
return res .status_code == 200
918
924
925
+ @utils .minimum_version ('1.25' )
926
+ def prune_containers (self , filters = None ):
927
+ """
928
+ Delete stopped containers
929
+
930
+ Args:
931
+ filters (dict): Filters to process on the prune list.
932
+
933
+ Returns:
934
+ (dict): A dict containing a list of deleted container IDs and
935
+ the amount of disk space reclaimed in bytes.
936
+
937
+ Raises:
938
+ :py:class:`docker.errors.APIError`
939
+ If the server returns an error.
940
+ """
941
+ params = {}
942
+ if filters :
943
+ params ['filters' ] = utils .convert_filters (filters )
944
+ url = self ._url ('/containers/prune' )
945
+ return self ._result (self ._post (url , params = params ), True )
946
+
919
947
@utils .check_resource
920
948
def remove_container (self , container , v = False , link = False , force = False ):
921
949
"""
0 commit comments