12
12
from .. import helpers
13
13
from ..helpers import assert_cat_socket_detached_with_keys
14
14
from ..helpers import ctrl_with
15
- from ..helpers import requires_api_version
15
+ from ..helpers import requires_api_version , skip_if_desktop
16
16
from .base import BaseAPIIntegrationTest
17
17
from .base import TEST_IMG
18
18
from docker .constants import IS_WINDOWS_PLATFORM
@@ -542,6 +542,27 @@ def test_create_with_binds_ro(self):
542
542
inspect_data = self .client .inspect_container (container )
543
543
self .check_container_data (inspect_data , False )
544
544
545
+ @skip_if_desktop ()
546
+ def test_create_with_binds_rw_rshared (self ):
547
+ container = self .run_with_volume_propagation (
548
+ False ,
549
+ 'rshared' ,
550
+ TEST_IMG ,
551
+ ['touch' , os .path .join (self .mount_dest , self .filename )],
552
+ )
553
+ inspect_data = self .client .inspect_container (container )
554
+ self .check_container_data (inspect_data , True , 'rshared' )
555
+ container = self .run_with_volume_propagation (
556
+ True ,
557
+ 'rshared' ,
558
+ TEST_IMG ,
559
+ ['ls' , self .mount_dest ],
560
+ )
561
+ logs = self .client .logs (container ).decode ('utf-8' )
562
+ assert self .filename in logs
563
+ inspect_data = self .client .inspect_container (container )
564
+ self .check_container_data (inspect_data , False , 'rshared' )
565
+
545
566
@requires_api_version ('1.30' )
546
567
def test_create_with_mounts (self ):
547
568
mount = docker .types .Mount (
@@ -597,7 +618,7 @@ def test_create_with_volume_mount(self):
597
618
assert mount ['Source' ] == mount_data ['Name' ]
598
619
assert mount_data ['RW' ] is True
599
620
600
- def check_container_data (self , inspect_data , rw ):
621
+ def check_container_data (self , inspect_data , rw , propagation = 'rprivate' ):
601
622
assert 'Mounts' in inspect_data
602
623
filtered = list (filter (
603
624
lambda x : x ['Destination' ] == self .mount_dest ,
@@ -607,6 +628,7 @@ def check_container_data(self, inspect_data, rw):
607
628
mount_data = filtered [0 ]
608
629
assert mount_data ['Source' ] == self .mount_origin
609
630
assert mount_data ['RW' ] == rw
631
+ assert mount_data ['Propagation' ] == propagation
610
632
611
633
def run_with_volume (self , ro , * args , ** kwargs ):
612
634
return self .run_container (
@@ -624,6 +646,23 @@ def run_with_volume(self, ro, *args, **kwargs):
624
646
** kwargs
625
647
)
626
648
649
+ def run_with_volume_propagation (self , ro , propagation , * args , ** kwargs ):
650
+ return self .run_container (
651
+ * args ,
652
+ volumes = {self .mount_dest : {}},
653
+ host_config = self .client .create_host_config (
654
+ binds = {
655
+ self .mount_origin : {
656
+ 'bind' : self .mount_dest ,
657
+ 'ro' : ro ,
658
+ 'propagation' : propagation
659
+ },
660
+ },
661
+ network_mode = 'none'
662
+ ),
663
+ ** kwargs
664
+ )
665
+
627
666
628
667
class ArchiveTest (BaseAPIIntegrationTest ):
629
668
def test_get_file_archive_from_container (self ):
0 commit comments