Skip to content

copy --parents silently ignores nonexistent paths #4900

Closed

Description

@blowfishpro

I didn't see this clearly documented so reporting as an issue.

When using the new COPY --parents option (in labs), it will silently skip over files that do not exist.

Compare the following:

Without --parents:

# syntax=docker/dockerfile:1.7-labs
FROM scratch
COPY ./nonexistent-file /

results in:

ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 520ef390-e014-48a2-bdd5-b7fb3e850763::43brx8ibsmqfjzdxft4n7es8p: "/nonexistent-file": not found

With --parents:

# syntax=docker/dockerfile:1.7-labs
FROM scratch AS parents
COPY --parents ./nonexistent-file /

Is successful even though the file doesn't exist.

From a quick read of the code, it appears to treat every source as a wildcard pattern with --parents even if it doesn't contain any wildcard characters. Wildcard paths that don't match anything are silently accepted with our without the --parents option. I do see a lot of historical issues and confusion relating to wildcards that don't match anything, but it seems like that aspect is intended behavior.

Activity

  1. tonistiigi commented on May 7, 2024

    @tonistiigi
    Member

    cc @DYefimov

    Looks bit unexpected indeed. It makes more sense with the internal API that is based on include patterns.

    In case you would use pivot point COPY --parents a/b/./c/d then the a/b part of the code would be validated.

    Additional question is what would happen with multiple paths. Or is the validation that if the pattern is not a wildcard then it needs to match.

    Unfortunately, it looks like this requires a new LLB option and can't be fixed by just a frontend update.

  2. blowfishpro commented on May 8, 2024

    @blowfishpro
    Author

    Broadly I would expect the same behavior with and without --parents with respect to what is validated.

  3. added this to the v0.next milestone on May 23, 2024
  4. modified the milestones: v0.14.0, v0.15.0 on Jun 6, 2024
  5. 4 remaining items

  6. added this to the v0.21.0 milestone on Feb 20, 2025
  7. modified the milestones: v0.21.0, v0.22.0 on Apr 7, 2025
  8. modified the milestones: v0.23.0, v0.24.0 on Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions