buildah icon indicating copy to clipboard operation
buildah copied to clipboard

Match docker behavior for `ADD` and `COPY` with globs if no file matches

Open thmo opened this issue 1 year ago • 6 comments

Trying to build with this Dockerfile:

from scratch
COPY non[e]xistant .

Describe the results you received:

$ buildah bud
STEP 1/2: FROM scratch
STEP 2/2: COPY non[e]xistant .
Error: building at STEP "COPY non[e]xistant .": checking on sources under "/tmp/u": Rel: can't make  relative to /tmp/u; copier: stat: ["/non[e]xistant"]: no such file or directory

Describe the results you expected:

Match current Docker behavior: COPY should not fail if there is not at least one file to copy.

Output of rpm -q buildah or apt list buildah: buildah-1.37.1-1.fc40.x86_64

Output of buildah version:

Version:         1.37.1
Go Version:      go1.22.6
Image Spec:      1.1.0
Runtime Spec:    1.2.0
CNI Spec:        1.1.0
libcni Version:  
image Version:   5.33.1
Git Commit:      
Built:           Thu Aug 15 21:59:01 2024
OS/Arch:         linux/amd64
BuildPlatform:   linux/amd64

thmo avatar Sep 17 '24 18:09 thmo

Yeah, this one's a surprise. Note to self: need to check if the docker build behavior depends on whether or not the glob includes wildcards or metacharacters, or if it's just always like that now.

nalind avatar Sep 18 '24 14:09 nalind

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Oct 19 '24 00:10 github-actions[bot]

@nalind What should we do with this one? Is there a difference between docker with and without buildkit?

rhatdan avatar Oct 21 '24 15:10 rhatdan

@rhatdan yes, depending on whether I set DOCKER_BUILDKIT to 0 or 1, this may or may not produce an error:

mkdir /tmp/glob; (echo FROM scratch; echo 'COPY b* .') > /tmp/glob/Dockerfile
docker build /tmp/glob

nalind avatar Oct 21 '24 17:10 nalind

Since we only want to match BUILDKIT, behavior, I take it Buildkit ignores no match?

rhatdan avatar Oct 21 '24 17:10 rhatdan

I tend to prefer offering an API toggle for the sake of tools that use us as a library. In this case, in my experience, if the source does not include any characters which would be treated as special (e.g., replace b* with b in the above example), an error is still produced.

nalind avatar Oct 21 '24 18:10 nalind

Hi

I'm having the same problem while trying to copy files that my not exists

mhkarimi1383 avatar Oct 26 '24 14:10 mhkarimi1383

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Nov 26 '24 00:11 github-actions[bot]

Are there any plans to resolve this?

johnlister avatar Nov 03 '25 11:11 johnlister