Dockerfile COPY with 'parents' flag in multistage build

Hi,

When we use the parents flag of the COPY in a multistage build, it seems it copies everything from the selected stage, not only the matching files.

OS build: I tested in on docker:latest based Linux image building with gitlab runner.
App version: This is a turbo monorepo with Next js 14 and prisma.

This is a sample syntax i used:

COPY --parents --from=installer --chown=nextjs:nodejs /app/node_modules/.pnpm/folder* …/

After the copy we even had these folders:

/app/node_modules/.pnpm
/app/node_modules/.cache

But it was not referenced anywhere.

When i use separate COPY command without the ‘parents’ flag, it works well.