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

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

Open
thmo opened this issue Sep 17, 2024 · 8 comments
Open

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

thmo opened this issue Sep 17, 2024 · 8 comments
Assignees

Comments

@thmo
Copy link

thmo commented Sep 17, 2024

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
@nalind
Copy link
Member

nalind commented Sep 18, 2024

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.

Copy link

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

@rhatdan
Copy link
Member

rhatdan commented Oct 21, 2024

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

@nalind
Copy link
Member

nalind commented Oct 21, 2024

@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

@rhatdan
Copy link
Member

rhatdan commented Oct 21, 2024

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

@nalind
Copy link
Member

nalind commented Oct 21, 2024

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.

@mhkarimi1383
Copy link

Hi

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

Copy link

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

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

4 participants