@@ -424,18 +424,6 @@ func (c *Container) init(allowCreate bool) error {
424
424
425
425
c .status .CreatedAt , _ = time .Parse (time .RFC3339Nano , cjson .Created )
426
426
427
- contConfig , err := c .containerConfig (cjson )
428
- if err != nil {
429
- c .Log (ERROR , err )
430
- return err
431
- }
432
- c .contConfig = contConfig
433
-
434
- if err != nil {
435
- c .Log (ERROR , err )
436
- return err
437
- }
438
-
439
427
c .mergeVolumes (cjson )
440
428
441
429
if ! loaded {
@@ -451,6 +439,13 @@ func (c *Container) init(allowCreate bool) error {
451
439
c .injectFiles (c .mountId )
452
440
}
453
441
442
+ contConfig , err := c .containerConfig (cjson )
443
+ if err != nil {
444
+ c .Log (ERROR , err )
445
+ return err
446
+ }
447
+ c .contConfig = contConfig
448
+
454
449
return nil
455
450
}
456
451
@@ -559,26 +554,54 @@ func (c *Container) cmdEnvs(envs []vc.EnvVar) []vc.EnvVar {
559
554
return envs
560
555
}
561
556
562
- func newMount (m dockertypes.MountPoint ) vc.Mount {
557
+ func newcMount (m dockertypes.MountPoint ) vc.Mount {
563
558
return vc.Mount {
564
559
Source : m .Source ,
565
560
Destination : m .Destination ,
566
561
}
567
562
}
568
563
569
- func containerMounts (cjson * dockertypes.ContainerJSON ) []vc.Mount {
564
+ func newOciMount (m dockertypes.MountPoint ) specs.Mount {
565
+ return specs.Mount {
566
+ Source : m .Source ,
567
+ Destination : m .Destination ,
568
+ }
569
+ }
570
+
571
+ func (c * Container ) containerOciMounts (cjson * dockertypes.ContainerJSON ) ([]vc.Mount , []specs.Mount ) {
570
572
cMounts := cjson .Mounts
571
573
572
- if cMounts == nil {
573
- return []vc.Mount {}
574
- }
574
+ var cmnts []vc.Mount
575
+ var ocimnts []specs.Mount
575
576
576
- var mnts []vc.Mount
577
577
for _ , m := range cMounts {
578
- mnts = append (mnts , newMount (m ))
578
+ cmnts = append (cmnts , newcMount (m ))
579
+ ocimnts = append (ocimnts , newOciMount (m ))
580
+ }
581
+
582
+ for _ , vol := range c .spec .Volumes {
583
+ if vol .Detail .Format == "vfs" {
584
+ cmnt := vc.Mount {
585
+ Source : vol .Detail .Source ,
586
+ Destination : vol .Path ,
587
+ Type : "bind" ,
588
+ ReadOnly : vol .ReadOnly ,
589
+ }
590
+
591
+ cmnts = append (cmnts , cmnt )
592
+
593
+ ocimnt := specs.Mount {
594
+ Source : vol .Detail .Source ,
595
+ Destination : vol .Path ,
596
+ Type : "bind" ,
597
+ Options : []string {"rbind" , "rprivate" },
598
+ }
599
+
600
+ ocimnts = append (ocimnts , ocimnt )
601
+ }
579
602
}
580
603
581
- return mnts
604
+ return cmnts , ocimnts
582
605
}
583
606
584
607
func (c * Container ) ociEnv () []string {
@@ -660,6 +683,11 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
660
683
oci .RemoveNamespace (ociSpec , ns )
661
684
}
662
685
686
+ cmnts , ocimnts := c .containerOciMounts (cjson )
687
+ for _ , mnt := range ocimnts {
688
+ ociSpec .Mounts = append (ociSpec .Mounts , mnt )
689
+ }
690
+
663
691
ociSpecJson , err := json .Marshal (ociSpec )
664
692
if err != nil {
665
693
return & vc.ContainerConfig {}, nil
@@ -704,7 +732,7 @@ func (c *Container) containerConfig(cjson *dockertypes.ContainerJSON) (*vc.Conta
704
732
vcAnnotations .ConfigJSONKey : string (ociSpecJson ),
705
733
vcAnnotations .BundlePathKey : path .Join (c .p .sandboxShareDir (), mountId ),
706
734
},
707
- Mounts : containerMounts ( cjson ) ,
735
+ Mounts : cmnts ,
708
736
}
709
737
710
738
c .Log (TRACE , "Container Info is \n %#v" , containerConfig )
0 commit comments