@@ -37,22 +37,6 @@ def test_list_containers(self):
37
37
38
38
39
39
class CreateContainerTest (api_test .BaseTestCase ):
40
- def setUp (self ):
41
- super (CreateContainerTest , self ).setUp ()
42
-
43
- self .mount_dest = '/mnt'
44
-
45
- # Get a random pathname - we don't need it to exist locally
46
- self .mount_origin = tempfile .mkdtemp ()
47
- shutil .rmtree (self .mount_origin )
48
-
49
- self .filename = 'shared.txt'
50
-
51
- self .run_with_volume (
52
- False ,
53
- BUSYBOX ,
54
- ['touch' , os .path .join (self .mount_dest , self .filename )],
55
- )
56
40
57
41
def test_create (self ):
58
42
res = self .client .create_container (BUSYBOX , 'true' )
@@ -176,35 +160,6 @@ def test_create_container_with_volumes_from(self):
176
160
info = self .client .inspect_container (res2 ['Id' ])
177
161
self .assertCountEqual (info ['HostConfig' ]['VolumesFrom' ], vol_names )
178
162
179
- def test_create_with_binds_rw (self ):
180
- container = self .run_with_volume (
181
- False ,
182
- BUSYBOX ,
183
- ['ls' , self .mount_dest ],
184
- )
185
- logs = self .client .logs (container )
186
-
187
- if six .PY3 :
188
- logs = logs .decode ('utf-8' )
189
- self .assertIn (self .filename , logs )
190
- inspect_data = self .client .inspect_container (container )
191
- self .check_container_data (inspect_data , True )
192
-
193
- def test_create_with_binds_ro (self ):
194
- container = self .run_with_volume (
195
- True ,
196
- BUSYBOX ,
197
- ['ls' , self .mount_dest ],
198
- )
199
- logs = self .client .logs (container )
200
-
201
- if six .PY3 :
202
- logs = logs .decode ('utf-8' )
203
- self .assertIn (self .filename , logs )
204
-
205
- inspect_data = self .client .inspect_container (container )
206
- self .check_container_data (inspect_data , False )
207
-
208
163
def create_container_readonly_fs (self ):
209
164
if not api_test .exec_driver_is_native ():
210
165
pytest .skip ('Exec driver not native' )
@@ -382,6 +337,59 @@ def test_valid_no_config_specified(self):
382
337
self .assertEqual (container_log_config ['Type' ], "json-file" )
383
338
self .assertEqual (container_log_config ['Config' ], {})
384
339
340
+
341
+ class VolumeBindTest (api_test .BaseTestCase ):
342
+ def setUp (self ):
343
+ super (VolumeBindTest , self ).setUp ()
344
+
345
+ self .mount_dest = '/mnt'
346
+
347
+ # Get a random pathname - we don't need it to exist locally
348
+ self .mount_origin = tempfile .mkdtemp ()
349
+ shutil .rmtree (self .mount_origin )
350
+ self .filename = 'shared.txt'
351
+
352
+ self .run_with_volume (
353
+ False ,
354
+ BUSYBOX ,
355
+ ['touch' , os .path .join (self .mount_dest , self .filename )],
356
+ )
357
+
358
+ def test_create_with_binds_rw (self ):
359
+
360
+ container = self .run_with_volume (
361
+ False ,
362
+ BUSYBOX ,
363
+ ['ls' , self .mount_dest ],
364
+ )
365
+ logs = self .client .logs (container )
366
+
367
+ if six .PY3 :
368
+ logs = logs .decode ('utf-8' )
369
+ self .assertIn (self .filename , logs )
370
+ inspect_data = self .client .inspect_container (container )
371
+ self .check_container_data (inspect_data , True )
372
+
373
+ def test_create_with_binds_ro (self ):
374
+ self .run_with_volume (
375
+ False ,
376
+ BUSYBOX ,
377
+ ['touch' , os .path .join (self .mount_dest , self .filename )],
378
+ )
379
+ container = self .run_with_volume (
380
+ True ,
381
+ BUSYBOX ,
382
+ ['ls' , self .mount_dest ],
383
+ )
384
+ logs = self .client .logs (container )
385
+
386
+ if six .PY3 :
387
+ logs = logs .decode ('utf-8' )
388
+ self .assertIn (self .filename , logs )
389
+
390
+ inspect_data = self .client .inspect_container (container )
391
+ self .check_container_data (inspect_data , False )
392
+
385
393
def check_container_data (self , inspect_data , rw ):
386
394
if docker .utils .compare_version ('1.20' , self .client ._version ) < 0 :
387
395
self .assertIn ('Volumes' , inspect_data )
0 commit comments