3
3
from collections import namedtuple
4
4
5
5
from ..api import APIClient
6
+ from ..constants import DEFAULT_DATA_CHUNK_SIZE
6
7
from ..errors import (ContainerError , ImageNotFound ,
7
8
create_unexpected_kwargs_error )
8
9
from ..types import HostConfig
@@ -181,26 +182,34 @@ def exec_run(self, cmd, stdout=True, stderr=True, stdin=False, tty=False,
181
182
exec_output
182
183
)
183
184
184
- def export (self ):
185
+ def export (self , chunk_size = DEFAULT_DATA_CHUNK_SIZE ):
185
186
"""
186
187
Export the contents of the container's filesystem as a tar archive.
187
188
189
+ Args:
190
+ chunk_size (int): The number of bytes returned by each iteration
191
+ of the generator. If ``None``, data will be streamed as it is
192
+ received. Default: 2 MB
193
+
188
194
Returns:
189
195
(str): The filesystem tar archive
190
196
191
197
Raises:
192
198
:py:class:`docker.errors.APIError`
193
199
If the server returns an error.
194
200
"""
195
- return self .client .api .export (self .id )
201
+ return self .client .api .export (self .id , chunk_size )
196
202
197
- def get_archive (self , path ):
203
+ def get_archive (self , path , chunk_size = DEFAULT_DATA_CHUNK_SIZE ):
198
204
"""
199
205
Retrieve a file or folder from the container in the form of a tar
200
206
archive.
201
207
202
208
Args:
203
209
path (str): Path to the file or folder to retrieve
210
+ chunk_size (int): The number of bytes returned by each iteration
211
+ of the generator. If ``None``, data will be streamed as it is
212
+ received. Default: 2 MB
204
213
205
214
Returns:
206
215
(tuple): First element is a raw tar data stream. Second element is
@@ -210,7 +219,7 @@ def get_archive(self, path):
210
219
:py:class:`docker.errors.APIError`
211
220
If the server returns an error.
212
221
"""
213
- return self .client .api .get_archive (self .id , path )
222
+ return self .client .api .get_archive (self .id , path , chunk_size )
214
223
215
224
def kill (self , signal = None ):
216
225
"""
@@ -515,6 +524,8 @@ def run(self, image, command=None, stdout=True, stderr=False,
515
524
(``0-3``, ``0,1``). Only effective on NUMA systems.
516
525
detach (bool): Run container in the background and return a
517
526
:py:class:`Container` object.
527
+ device_cgroup_rules (:py:class:`list`): A list of cgroup rules to
528
+ apply to the container.
518
529
device_read_bps: Limit read rate (bytes per second) from a device
519
530
in the form of: `[{"Path": "device_path", "Rate": rate}]`
520
531
device_read_iops: Limit read rate (IO per second) from a device.
@@ -912,6 +923,7 @@ def prune(self, filters=None):
912
923
'cpuset_mems' ,
913
924
'cpu_rt_period' ,
914
925
'cpu_rt_runtime' ,
926
+ 'device_cgroup_rules' ,
915
927
'device_read_bps' ,
916
928
'device_read_iops' ,
917
929
'device_write_bps' ,
0 commit comments