@@ -24,6 +24,7 @@ import (
2424 "github.com/docker/docker/daemon"
2525 imagepkg "github.com/docker/docker/image"
2626 "github.com/docker/docker/pkg/archive"
27+ "github.com/docker/docker/pkg/chrootarchive"
2728 "github.com/docker/docker/pkg/parsers"
2829 "github.com/docker/docker/pkg/symlink"
2930 "github.com/docker/docker/pkg/system"
@@ -46,7 +47,9 @@ func (b *Builder) readContext(context io.Reader) error {
4647 if b .context , err = tarsum .NewTarSum (decompressedStream , true , tarsum .Version0 ); err != nil {
4748 return err
4849 }
49- if err := archive .Untar (b .context , tmpdirPath , nil ); err != nil {
50+
51+ os .MkdirAll (tmpdirPath , 0700 )
52+ if err := chrootarchive .Untar (b .context , tmpdirPath , nil ); err != nil {
5053 return err
5154 }
5255
@@ -627,7 +630,7 @@ func (b *Builder) addContext(container *daemon.Container, orig, dest string, dec
627630 }
628631
629632 // try to successfully untar the orig
630- if err := archive .UntarPath (origPath , tarDest ); err == nil {
633+ if err := chrootarchive .UntarPath (origPath , tarDest ); err == nil {
631634 return nil
632635 } else if err != io .EOF {
633636 log .Debugf ("Couldn't untar %s to %s: %s" , origPath , tarDest , err )
@@ -637,7 +640,7 @@ func (b *Builder) addContext(container *daemon.Container, orig, dest string, dec
637640 if err := os .MkdirAll (path .Dir (destPath ), 0755 ); err != nil {
638641 return err
639642 }
640- if err := archive .CopyWithTar (origPath , destPath ); err != nil {
643+ if err := chrootarchive .CopyWithTar (origPath , destPath ); err != nil {
641644 return err
642645 }
643646
@@ -650,7 +653,7 @@ func (b *Builder) addContext(container *daemon.Container, orig, dest string, dec
650653}
651654
652655func copyAsDirectory (source , destination string , destinationExists bool ) error {
653- if err := archive .CopyWithTar (source , destination ); err != nil {
656+ if err := chrootarchive .CopyWithTar (source , destination ); err != nil {
654657 return err
655658 }
656659
0 commit comments