We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7382eb1 commit 161bfbaCopy full SHA for 161bfba
docker/api/container.py
@@ -549,6 +549,8 @@ def create_host_config(self, *args, **kwargs):
549
security_opt (:py:class:`list`): A list of string values to
550
customize labels for MLS systems, such as SELinux.
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.
554
sysctls (dict): Kernel parameters to set in the container.
555
tmpfs (dict): Temporary filesystems to mount, as a dictionary
556
mapping a path inside the container to options for that path.
docker/models/containers.py
@@ -586,6 +586,8 @@ def run(self, image, command=None, stdout=True, stderr=False,
586
Default: ``False``.
587
stop_signal (str): The stop signal to use to stop the container
588
(e.g. ``SIGINT``).
589
590
591
592
593
@@ -833,6 +835,7 @@ def prune(self, filters=None):
833
835
'restart_policy',
834
836
'security_opt',
837
'shm_size',
838
+ 'storage_opt',
839
'sysctls',
840
'tmpfs',
841
'ulimits',
docker/types/containers.py
@@ -117,7 +117,7 @@ def __init__(self, version, binds=None, port_bindings=None,
117
oom_kill_disable=False, shm_size=None, sysctls=None,
118
tmpfs=None, oom_score_adj=None, dns_opt=None, cpu_shares=None,
119
cpuset_cpus=None, userns_mode=None, pids_limit=None,
120
- isolation=None, auto_remove=False):
+ isolation=None, auto_remove=False, storage_opt=None):
121
122
if mem_limit is not None:
123
self['Memory'] = parse_bytes(mem_limit)
@@ -412,6 +412,11 @@ def __init__(self, version, binds=None, port_bindings=None,
412
raise host_config_version_error('auto_remove', '1.25')
413
self['AutoRemove'] = auto_remove
414
415
+ if storage_opt is not None:
416
+ if version_lt(version, '1.24'):
417
+ raise host_config_version_error('storage_opt', '1.24')
418
+ self['StorageOpt'] = storage_opt
419
+
420
421
def host_config_type_error(param, param_value, expected):
422
error_msg = 'Invalid type for {0} param: expected {1} but found {2}'
tests/integration/api_container_test.py
@@ -422,6 +422,22 @@ def test_create_with_stop_timeout(self):
config = self.client.inspect_container(container)
423
assert config['Config']['StopTimeout'] == 25
424
425
+ @requires_api_version('1.24')
426
+ def test_create_with_storage_opt(self):
427
+ if self.client.info()['Driver'] == 'aufs':
428
+ return pytest.skip('Not supported on AUFS')
429
+ host_config = self.client.create_host_config(
430
+ storage_opt={'size': '120G'}
431
+ )
432
+ container = self.client.create_container(
433
+ BUSYBOX, ['echo', 'test'], host_config=host_config
434
435
+ self.tmp_containers.append(container)
436
+ config = self.client.inspect_container(container)
437
+ assert config['HostConfig']['StorageOpt'] == {
438
+ 'size': '120G'
439
+ }
440
441
442
class VolumeBindTest(BaseAPIIntegrationTest):
443
def setUp(self):
tests/integration/base.py
@@ -75,6 +75,10 @@ def setUp(self):
75
version=TEST_API_VERSION, timeout=60, **kwargs_from_env()
76
)
77
78
+ def tearDown(self):
79
+ super(BaseAPIIntegrationTest, self).tearDown()
80
+ self.client.close()
81
82
def run_container(self, *args, **kwargs):
83
container = self.client.create_container(*args, **kwargs)
84
self.tmp_containers.append(container)
0 commit comments