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

Copy command's --exclude option fails to exclude from subdirectories #5509

Closed
codebling opened this issue Nov 11, 2024 · 2 comments
Closed

Comments

@codebling
Copy link

See also #5489

Example repo

The exclude option correctly excludes files from the top-level directory in a COPY command, but incorrectly copies files matching the exclude pattern in subdirectories.

To reproduce, create a directory structure:

dir1/a.1
dir1/a.2
dir1/dir2/a.1
dir1/dir2/a.2
Dockerfile

and add these contents to the Dockerfile:

# syntax=docker.io/docker/dockerfile:1.11.1-labs
FROM scratch
COPY --exclude=*.1 dir1 .

The resulting file structure in the image will be:

dir2/a.2
dir2/a.1
a.2

a.1 is correctly excluded at the top level, but a.1 in the subdirectory is incorrectly copied

@tonistiigi
Copy link
Member

This is the same pattern rules as .dockerignore https://docs.docker.com/build/concepts/context/#dockerignore-files . You would need to use **/*.1 for files under any level of subdirectory.

@codebling
Copy link
Author

Confirmed **/*.1 works. Sorry for the spam

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

No branches or pull requests

2 participants