@@ -598,6 +598,60 @@ def test_create_with_mounts_ro(self):
598
598
inspect_data = self .client .inspect_container (container )
599
599
self .check_container_data (inspect_data , False )
600
600
601
+ @requires_api_version ('1.41' )
602
+ def test_create_with_mounts_recursive_disabled (self ):
603
+ mount = docker .types .Mount (
604
+ type = "bind" , source = self .mount_origin , target = self .mount_dest ,
605
+ read_only = True , recursive = "disabled"
606
+ )
607
+ host_config = self .client .create_host_config (mounts = [mount ])
608
+ container = self .run_container (
609
+ TEST_IMG , ['ls' , self .mount_dest ],
610
+ host_config = host_config
611
+ )
612
+ assert container
613
+ logs = self .client .logs (container ).decode ('utf-8' )
614
+ assert self .filename in logs
615
+ inspect_data = self .client .inspect_container (container )
616
+ self .check_container_data (inspect_data , False ,
617
+ bind_options_field = "NonRecursive" )
618
+
619
+ @requires_api_version ('1.44' )
620
+ def test_create_with_mounts_recursive_writable (self ):
621
+ mount = docker .types .Mount (
622
+ type = "bind" , source = self .mount_origin , target = self .mount_dest ,
623
+ read_only = True , recursive = "writable"
624
+ )
625
+ host_config = self .client .create_host_config (mounts = [mount ])
626
+ container = self .run_container (
627
+ TEST_IMG , ['ls' , self .mount_dest ],
628
+ host_config = host_config
629
+ )
630
+ assert container
631
+ logs = self .client .logs (container ).decode ('utf-8' )
632
+ assert self .filename in logs
633
+ inspect_data = self .client .inspect_container (container )
634
+ self .check_container_data (inspect_data , False ,
635
+ bind_options_field = "ReadOnlyNonRecursive" )
636
+
637
+ @requires_api_version ('1.44' )
638
+ def test_create_with_mounts_recursive_ro (self ):
639
+ mount = docker .types .Mount (
640
+ type = "bind" , source = self .mount_origin , target = self .mount_dest ,
641
+ read_only = True , recursive = "readonly"
642
+ )
643
+ host_config = self .client .create_host_config (mounts = [mount ])
644
+ container = self .run_container (
645
+ TEST_IMG , ['ls' , self .mount_dest ],
646
+ host_config = host_config
647
+ )
648
+ assert container
649
+ logs = self .client .logs (container ).decode ('utf-8' )
650
+ assert self .filename in logs
651
+ inspect_data = self .client .inspect_container (container )
652
+ self .check_container_data (inspect_data , False ,
653
+ bind_options_field = "ReadOnlyForceRecursive" )
654
+
601
655
@requires_api_version ('1.30' )
602
656
def test_create_with_volume_mount (self ):
603
657
mount = docker .types .Mount (
@@ -620,7 +674,8 @@ def test_create_with_volume_mount(self):
620
674
assert mount ['Source' ] == mount_data ['Name' ]
621
675
assert mount_data ['RW' ] is True
622
676
623
- def check_container_data (self , inspect_data , rw , propagation = 'rprivate' ):
677
+ def check_container_data (self , inspect_data , rw , propagation = 'rprivate' ,
678
+ bind_options_field = None ):
624
679
assert 'Mounts' in inspect_data
625
680
filtered = list (filter (
626
681
lambda x : x ['Destination' ] == self .mount_dest ,
@@ -631,6 +686,18 @@ def check_container_data(self, inspect_data, rw, propagation='rprivate'):
631
686
assert mount_data ['Source' ] == self .mount_origin
632
687
assert mount_data ['RW' ] == rw
633
688
assert mount_data ['Propagation' ] == propagation
689
+ if bind_options_field :
690
+ assert 'Mounts' in inspect_data ['HostConfig' ]
691
+ mounts = [
692
+ x for x in inspect_data ['HostConfig' ]['Mounts' ]
693
+ if x ['Target' ] == self .mount_dest
694
+ ]
695
+ assert len (mounts ) == 1
696
+ mount = mounts [0 ]
697
+ assert 'BindOptions' in mount
698
+ bind_options = mount ['BindOptions' ]
699
+ assert bind_options_field in bind_options
700
+ assert bind_options [bind_options_field ] is True
634
701
635
702
def run_with_volume (self , ro , * args , ** kwargs ):
636
703
return self .run_container (
0 commit comments