@@ -550,15 +550,36 @@ func (p *v2Puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *s
550
550
)
551
551
552
552
// https://github.com/docker/docker/issues/24766 - Err on the side of caution,
553
- // explicitly blocking images intended for linux from the Windows daemon
554
- if runtime .GOOS == "windows" && unmarshalledConfig .OS == "linux" {
555
- return "" , "" , fmt .Errorf ("image operating system %q cannot be used on this platform" , unmarshalledConfig .OS )
553
+ // explicitly blocking images intended for linux from the Windows daemon. On
554
+ // Windows, we do this before the attempt to download, effectively serialising
555
+ // the download slightly slowing it down. We have to do it this way, as
556
+ // chances are the download of layers itself would fail due to file names
557
+ // which aren't suitable for NTFS. At some point in the future, if a similar
558
+ // check to block Windows images being pulled on Linux is implemented, it
559
+ // may be necessary to perform the same type of serialisation.
560
+ if runtime .GOOS == "windows" {
561
+ configJSON , unmarshalledConfig , err = receiveConfig (configChan , errChan )
562
+ if err != nil {
563
+ return "" , "" , err
564
+ }
565
+
566
+ if unmarshalledConfig .RootFS == nil {
567
+ return "" , "" , errRootFSInvalid
568
+ }
569
+
570
+ if unmarshalledConfig .OS == "linux" {
571
+ return "" , "" , fmt .Errorf ("image operating system %q cannot be used on this platform" , unmarshalledConfig .OS )
572
+ }
556
573
}
557
574
558
575
downloadRootFS = * image .NewRootFS ()
559
576
560
577
rootFS , release , err := p .config .DownloadManager .Download (ctx , downloadRootFS , descriptors , p .config .ProgressOutput )
561
578
if err != nil {
579
+ if configJSON != nil {
580
+ // Already received the config
581
+ return "" , "" , err
582
+ }
562
583
select {
563
584
case err = <- errChan :
564
585
return "" , "" , err
@@ -573,13 +594,15 @@ func (p *v2Puller) pullSchema2(ctx context.Context, ref reference.Named, mfst *s
573
594
}
574
595
defer release ()
575
596
576
- configJSON , unmarshalledConfig , err = receiveConfig (configChan , errChan )
577
- if err != nil {
578
- return "" , "" , err
579
- }
597
+ if configJSON == nil {
598
+ configJSON , unmarshalledConfig , err = receiveConfig (configChan , errChan )
599
+ if err != nil {
600
+ return "" , "" , err
601
+ }
580
602
581
- if unmarshalledConfig .RootFS == nil {
582
- return "" , "" , errRootFSInvalid
603
+ if unmarshalledConfig .RootFS == nil {
604
+ return "" , "" , errRootFSInvalid
605
+ }
583
606
}
584
607
585
608
// The DiffIDs returned in rootFS MUST match those in the config.
0 commit comments