Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use custom build output with multiple child directories on windows #2433

Open
3 tasks done
jamie-sherriff opened this issue Apr 26, 2024 · 5 comments
Open
3 tasks done

Comments

@jamie-sherriff
Copy link

jamie-sherriff commented Apr 26, 2024

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I am trying to export several child/nested directories from containers using custom buildkit outputs with a cli command.
buildx build --target export-stage --output type=local, dest=./dist .

The command works in WSL and Linux fine but not Windows. This used to work for me on Windows 10 but no longer does, i am unsure when this was regressed or is a windows 11 limitation.

Expected behaviour

Nested child directories should be able to be copied, build kit commands should produce the same output between windows or Linux. In this example i am expecting childir/grandchilddir to be output from the build output into the dest directory.

Actual behaviour

Receive the error on windows 11:
ERROR: failed to solve: error from receiver: context canceled

Buildx version

github.com/docker/buildx v0.13.1-desktop.1 2368b2ee41873b948cb607251cec573ed00f00f9

Docker info

Client:
 Version:    26.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.1-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.27
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.23
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.6.3
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 8
  Running: 7
  Paused: 0
  Stopped: 1
 Images: 17
 Server Version: 26.0.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.146.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 24
 Total Memory: 31.27GiB
 Name: docker-desktop
 ID: db2e6bd7-1884-4a1f-809e-c12a733b62a2
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=npipe://\\.\pipe\docker_cli
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: daemon is not using the default seccomp profile

Builders list

NAME/NODE           DRIVER/ENDPOINT     STATUS    BUILDKIT   PLATFORMS
default*            docker
 \_ default          \_ default         running   v0.13.1    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6
desktop-linux       docker
 \_ desktop-linux    \_ desktop-linux   running   v0.13.1    linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6

Configuration

FROM  alpine as base
WORKDIR /usr/src/app

RUN mkdir childir
RUN mkdir childir/grandchilddir

RUN echo "this is a line" > toplevel.txt

FROM scratch AS export-stage
COPY --from=base usr/src/app/ .
docker buildx build --no-cache --target export-stage --output type=local,dest=./dist .

Build logs

docker buildx build --no-cache --target export-stage --output type=local,dest=./dist .
2024/04/26 15:10:00 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
2024/04/26 15:10:00 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
[+] Building 3.0s (10/10) FINISHED                                                                                               docker:default
 => [internal] load build definition from Dockerfile                                                                                       0.0s
 => => transferring dockerfile: 495B                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                           1.5s
 => [internal] load .dockerignore                                                                                                          0.0s
 => => transferring context: 2B                                                                                                            0.0s
 => [base 1/5] FROM docker.io/library/alpine:latest@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b                0.0s
 => CACHED [base 2/5] WORKDIR /usr/src/app                                                                                                 0.0s
 => [base 3/5] RUN mkdir childir                                                                                                           0.3s
 => [base 4/5] RUN mkdir childir/grandchilddir                                                                                             0.4s
 => [base 5/5] RUN echo "this is a line" > toplevel.txt                                                                                    0.5s
 => [export-stage 1/1] COPY --from=base usr/src/app/ .                                                                                     0.0s
 => CANCELED exporting to client directory                                                                                                 0.0s
 => => copying files 99B                                                                                                                   0.0s
ERROR: failed to solve: error from receiver: context canceled

Additional info

Using cli command
docker buildx build --no-cache --target export-stage --output type=local,dest=./dist .

Exact same command works in WSL2 or linux (Ubuntu 22.04)

Using Windows 11 23H1 Build 22631/3447

Removing the dockerfile line:
RUN mkdir childir/grandchilddir
Gets it working so leaves me to assume this is related due to nested directories.

Work around would be to tar up the directory and then untar it in windows but would prefer a minimal multiplatform solution. If the nested child directories are empty or not does not seem to matter.

@tonistiigi
Copy link
Member

@jamie-sherriff Do you have a reproducer?

@profnandaa Can you check if you can verify this.

@jamie-sherriff
Copy link
Author

Hey @tonistiigi Yup, minimal Docker file and command to reproduce is in the configuration section, but also copied below

FROM  alpine as base
WORKDIR /usr/src/app

RUN mkdir childir
RUN mkdir childir/grandchilddir

RUN echo "this is a line" > toplevel.txt

FROM scratch AS export-stage
COPY --from=base usr/src/app/ .
docker buildx build --no-cache --target export-stage --output type=local,dest=./dist .

Also of note, i have reproduced on a separate windows machine Windows 10 22H2 1905.4291. This was using docker desktop 4.29 and the buildkit version appears to be the same being:

[github.com/docker/buildx](http://github.com/docker/buildx) v0.13.1-desktop.1 2368b2ee41873b948cb607251cec573ed00f00f9

@profnandaa
Copy link

profnandaa commented May 13, 2024

@tonistiigi -- I can repro this too, getting the same:

docker buildx build --progress plain --no-cache --target export-stage --output type=local,dest=./dist .
2024/05/13 14:18:44 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
#0 building with "default" instance using docker driver

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

#2 [internal] load metadata for docker.io/library/alpine:latest
#2 DONE 0.0s

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

#4 [base 1/5] FROM docker.io/library/alpine:latest
#4 DONE 0.0s

#5 [base 2/5] WORKDIR /usr/src/app
#5 CACHED

#6 [base 3/5] RUN mkdir childir
#6 DONE 0.3s

#7 [base 4/5] RUN mkdir childir/grandchilddir
#7 DONE 0.4s

#8 [base 5/5] RUN echo "this is a line" > toplevel.txt
#8 DONE 0.5s

#9 [export-stage 1/1] COPY --from=base usr/src/app/ .
#9 DONE 0.0s

#10 exporting to client directory
#10 copying files 99B done
#10 CANCELED
ERROR: failed to solve: error from receiver: context canceled

However, removing the RUN mkdir childdir/grandchilddir line works.
Also wondering what's with the http2 errors.

docker buildx build --progress plain --no-cache --target export-stage --output type=local,dest=./dist .
2024/05/13 14:19:01 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
2024/05/13 14:19:01 http2: server: error reading preface from client //./pipe/docker_engine: file has already been closed
#0 building with "default" instance using docker driver

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

#2 [internal] load metadata for docker.io/library/alpine:latest
#2 DONE 0.0s

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

#4 [base 1/4] FROM docker.io/library/alpine:latest
#4 DONE 0.0s

#5 [base 2/4] WORKDIR /usr/src/app
#5 CACHED

#6 [base 3/4] RUN mkdir childir
#6 DONE 0.3s

#7 [base 4/4] RUN echo "this is a line" > toplevel.txt
#7 DONE 0.4s

#8 [export-stage 1/1] COPY --from=base usr/src/app/ .
#8 DONE 0.0s

#9 exporting to client directory
#9 copying files 79B done
#9 DONE 0.0s

QQ. how can I swap the backends to test with Buildkit v0.13.2?

@profnandaa
Copy link

Same repro even with v0.13.2, investigating.

docker buildx create --name buildkit-13-2 --driver-opt image=moby/buildkit:v0.13.2 --bootstrap

@alexhowgego
Copy link

Same over here. Upgraded to latest Docker yesterday and still getting the same issue.

I hadn't seen this thread previously but here is my write-up on SO (for an additional worked example):

https://stackoverflow.com/questions/78488942/docker-buildkit-context-canceled-when-output-contains-subdirectories-docker-4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants