moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
8.21k stars 1.16k forks source link

buildctl fails on Windows with "archive/tar: invalid tar header" #5528

Open TinaMor opened 4 hours ago

TinaMor commented 4 hours ago

Description

buildctl fails on Windows with "archive/tar: invalid tar header" for both type=oci and type=docker using CMD or PowerShell.

> buildctl.exe build --progress=tty --frontend=dockerfile.v0 --local=context=. --output=type=docker,name=test/hello-buildkit,push=false --local=dockerfile=./ --opt=filename=Dockerfile | docker load

archive/tar: invalid tar header
error: failed to solve: failed to copy to tar: rpc error: code = Unknown desc = write /dev/stdout: The pipe is being closed.

Test Dockerfile

FROM mcr.microsoft.com/windows/nanoserver:ltsc2022   
RUN echo "hello"

Image

Additional info

Using --progress plain works

> buildctl.exe build --progress=plain --frontend=dockerfile.v0 --local=context=. --output=type=docker,name=test/hello-buildkit,push=false --local=dockerfile=./ --opt=filename=Dockerfile | docker load

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 108B done
#1 DONE 0.0s

#2 [internal] load metadata for mcr.microsoft.com/windows/nanoserver:ltsc2022
#2 DONE 0.3s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/2] FROM mcr.microsoft.com/windows/nanoserver:ltsc2022@sha256:be37c9e8bf388c4e3ef27b4a2592b94adab551e231644ce3c9d4d3dc0a50af41
#4 resolve mcr.microsoft.com/windows/nanoserver:ltsc2022@sha256:be37c9e8bf388c4e3ef27b4a2592b94adab551e231644ce3c9d4d3dc0a50af41 0.0s done
#4 DONE 0.0s

#5 [2/2] RUN echo "hello"
#5 CACHED

#6 exporting to docker image format
#6 exporting layers done
#6 exporting manifest sha256:5beace3848b86d36f96ada17197ca4558cb4ae79608610094cc878529bb578d7 0.0s done
#6 exporting config sha256:72a13ebdd2882395f1acaa8af867ed4d48993d7cd153a566aa135f12c96efeb4 0.0s done
#6 sending tarball
#6 sending tarball 4.2s done
#6 DONE 4.2s
afe057336777: Loading layer [==================================================>]  116.9MB/116.9MB
35185b6eab61: Loading layer [==================================================>]  73.08kB/73.08kB
Loaded image: test/hello-buildkit:latest

Environment

  1. Windows ProductName : Windows Server 2022 Datacenter Evaluation ReleaseId : 2009 CurrentBuild : 20348 DisplayVersion : 21H2
  2. buildctl buildctl github.com/moby/buildkit v0.17.1 8b1b83ef4947c03062cdcdb40c69989d8fe3fd04
  3. docker Image
TinaMor commented 4 hours ago

May be caused by https://github.com/containerd/console: https://github.com/containerd/console/issues/83

profnandaa commented 2 hours ago

What do you get on the CMD shell?

TinaMor commented 1 hour ago

Same error:

> C:\Windows\System32>buildctl.exe build --progress=tty --frontend=dockerfile.v0 --local=context=. --output=type=oci,name=test/hello-buildkit,push=false --local=dockerfile=./ --opt=filename=Dockerfile | docker load

archive/tar: invalid tar header
error: failed to solve: failed to copy to tar: rpc error: code = Unknown desc = write /dev/stdout: The pipe is being closed.

Image