docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.54k stars 481 forks source link

Buildx can't handle non-ASCII directory name when using ADD/COPY. #1684

Closed s2marine closed 1 year ago

s2marine commented 1 year ago

Contributing guidelines

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

Description

Buildx can't handle non-ASCII directory name when using ADD/COPY.

Expected behaviour

build should success.

Actual behaviour

ERROR: failed to solve: Internal: header key "followpaths" contains value with non-printable ASCII characters

Buildx version

github.com/docker/buildx 0.10.3 79e156beb11f697f06ac67fa1fb958e4762c0fab

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.10.3
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.16.0
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 11
 Server Version: 23.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.2.6-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.27GiB
 Name: ArchLinux-y7000-s2marine
 ID: WAB6:2ZHY:LMZO:JA6R:36U5:LNBO:QRDD:NRWI:NIPE:LGBD:LIE3:M4QX
 Docker Root Dir: /media/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Builders list

NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT PLATFORMS
default * docker
  default default         running 23.0.1   linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Configuration

FROM alpine
ADD ./中文路径 /build
RUN echo success!
$ mkdir 中文路径
$ docker buildx build .

Logs

[+] Building 0.1s (5/6)
 => [internal] load .dockerignore                                                                                                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                        0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 76B                                                                                                                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                                                                                       0.0s
 => ERROR [internal] load build context                                                                                                                                                                                                                                                0.0s
 => => transferring context:                                                                                                                                                                                                                                                           0.0s
 => CACHED [1/2] FROM docker.io/library/alpine                                                                                                                                                                                                                                         0.0s
------
 > [internal] load build context:
------
ERROR: failed to solve: Internal: header key "followpaths" contains value with non-printable ASCII characters

Additional info

No response

anissa218 commented 1 year ago

HI, have you found a solution to this issue?

jedevc commented 1 year ago

This looks like a duplicate of https://github.com/moby/buildkit/issues/3927, which was fixed by https://github.com/moby/buildkit/pull/3946 (which is part of https://github.com/moby/buildkit/releases/tag/v0.12.0).

Upgrading to the latest buildx v0.11.2 should contain the fix (also ensure that if you're running buildkit manually (e.g. in kubernetes), that it is also updated to buildkit v0.12).

chrissound commented 6 months ago

I think this is still an issue in some cases.

I ran into this error when I was passing a parameter to docker build -f $example where example contained a newline at the end... I think this error message should be improved as well - to indicate it's the parameter as opposed to files.

This also happened after upgrading to the latest docker.

devops_staging@staging:~$ my_variable=$'example\n'
devops_staging@staging:~$ docker build -f "$my_variable"
docker buildx version
github.com/docker/buildx v0.13.1 7884339
sudo docker version
Client: Docker Engine - Community
 Version:           26.0.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        d260a54
 Built:             Thu Apr 11 10:53:52 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       60b9add
  Built:            Thu Apr 11 10:53:52 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0