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 --exclude does not exclude any files when source is not a directory #5489

Open
codebling opened this issue Nov 6, 2024 · 3 comments
Open

Comments

@codebling
Copy link

To reproduce, create two empty files, a and b, and a Dockerfile with the following contents:

# syntax=docker/dockerfile:1.7-labs
FROM scratch
COPY --exclude=a * .

The files a and b appear in the image.
This is contrary to the documentation, which states

to add all files starting with "hom", excluding files with a .txt extension:
COPY --exclude=*.txt hom* /mydir/

If the source is a directory, as in the slightly modified version of the Dockerfile above, a is not copied.

# syntax=docker/dockerfile:1.7-labs
FROM scratch
COPY --exclude=a . .
@codebling
Copy link
Author

See also #4561

@codebling codebling changed the title COPY --exclude fails when source is not a directory COPY --exclude does not exclude any fiels when source is not a directory Nov 6, 2024
@codebling codebling changed the title COPY --exclude does not exclude any fiels when source is not a directory COPY --exclude does not exclude any files when source is not a directory Nov 6, 2024
@tonistiigi
Copy link
Member

cc @jsternberg , not sure if related to #4946

@codebling
Copy link
Author

not sure if related to #4946

Based on this comment,

The reason why this seems to affect --exclude is because exclude is forcing the checksum to compute which paths it's allowed to follow and the broken symlink just happens to be included.

it looks like this issue is not related to that one, but I'm no expert here.

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