From 0c20554f69a3da246ab3cc5a11b69361ac489758 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 21 Mar 2019 15:26:59 -0700 Subject: [PATCH] image build: fix archive detection As pointed out in #1459, docker cli fails to detect that the input is a tarball, in case it is generated by `git archive --format=tgz`. This happens because `git archive` adds some metadata to the initial tar header, and so it is more than 1 block (of 512 bytes) long, while we only provide 1 block to archive/tar.Next() and it fails. To fix, give it 2 blocks :) Signed-off-by: Kir Kolyshkin --- cli/command/image/build/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/image/build/context.go b/cli/command/image/build/context.go index b7170df88e..5d0e96737d 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -89,7 +89,7 @@ func ValidateContextDirectory(srcPath string, excludes []string) error { func DetectArchiveReader(input io.ReadCloser) (rc io.ReadCloser, isArchive bool, err error) { buf := bufio.NewReader(input) - magic, err := buf.Peek(archiveHeaderSize) + magic, err := buf.Peek(archiveHeaderSize * 2) if err != nil && err != io.EOF { return nil, false, errors.Errorf("failed to peek context header from STDIN: %v", err) }