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

Multiple levels of wildcards not supported or not working properly #1900

Open
csMACnz opened this issue Dec 15, 2020 · 15 comments
Open

Multiple levels of wildcards not supported or not working properly #1900

csMACnz opened this issue Dec 15, 2020 · 15 comments
Labels
area/feature-parity Feature parity with classic builder status/needs-investigation

Comments

@csMACnz
Copy link

csMACnz commented Dec 15, 2020

I used to be able to copy all files of a specific type from two-levels nested. This no longer works in BuildKit.

Why? To avoid cache busting. We want to restore our dependencies from all *.csproj files, and not invalidate that cache layer when a source file changes.

see https://stackoverflow.com/a/58697043 as the defacto approach most dotnet docker builds will be using.

If we just copy everything over first, that means any change triggers cache-busting and a full package restore is again required. Without wildcards, we have to manually maintain a long list of csproj file COPYs that is error-prone and unmaintainable across many solutions.

# These all worked without buildkit but now fail with buildkit
COPY src/*/*.csproj ./
COPY */*/*.csproj ./

This puts all found files into a single folder (which at least works for the goal we are trying to achieve)

I now get errors like:

error from sender: readdir: open *: The filename, directory name, or volume label syntax is incorrect.

or sometimes nothing is copied, so i get missing files errors later in the next RUN command.

As far as I an tell, COPY */*.csproj ./ still works as expected, when csproj files are only one-level nested, but doesn't work for the two-level nested case.

As a workaround, I might be able to move to a one-level nested structure, though ideally i wouldn't have to change my structure to fit docker for something that used to work?

Thanks!

@pierregorce
Copy link

pierregorce commented Dec 22, 2020

I'm having the same problem while configuring buildkit for same caching purpose in .NET. Is there an alternative ?

COPY */*.csproj ./ (with one-level nested) not working either, is there a tricks ?

Thanks 😊

@tonistiigi tonistiigi added area/feature-parity Feature parity with classic builder status/needs-investigation labels Jan 4, 2021
@tonistiigi tonistiigi changed the title Wildcards no longer work the same way with BuildKit Multiple levels of wildcards not supported or not working properly Mar 11, 2021
@gvanbrakel
Copy link

gvanbrakel commented Mar 11, 2021

I don't think it is about multiple level of wildcards. When I run the below script, that has only one level of wildcard, it fails:

mkdir project-x-dependencies

echo "line-of-text" > project-x-dependencies/file1.txt
	
echo FROM busybox > Dockerfile
echo COPY project-*-dependencies/file1.txt  /work/ >> Dockerfile

docker build .

It appears to me that it is about wildcards in directories.

@YoeriVD
Copy link

YoeriVD commented Mar 26, 2021

"needs investigation"

Any update on this? after the last update, no one in our team using the windows version of docker can build their images anymore :/

EDIT:
Fellow googlers (temp) fix can be found here
moby/moby#42133 (comment)

@sbabych
Copy link

sbabych commented Apr 13, 2021

Good morning,
in our case we have smth like:
COPY ./drivers/build/3rdparty-jdbc-drivers/**/* jars/3rdparty/
and with "buildkit": true it doesn't work

@qrjo
Copy link

qrjo commented Apr 15, 2021

If this is gonna be fixed, it would be nice have a way to have these wildcards and preserve the folder structure as well.

@ASHWINI-GUPTA
Copy link

Same issue happened while I was trying to build the - https://github.com/Squidex/squidex.
After setting "buildkit": false was able to build but resetting "buildkit": true its giving an error from sender: readdir: open backend\extensions\*: The filename, directory name, or volume label syntax is incorrect..

@vchirikov
Copy link

vchirikov commented Oct 16, 2021

Same with

COPY src/dotnet/*/*.csproj ./

doesn't work with buildkit, works fine without buildkit

@Schwaller
Copy link

Schwaller commented Dec 15, 2021

Please fix this - it's creating so much work and can't be that difficult to solve this - please. IMHO this ticket doesn't need any investigation, it needs solving :D (talking of labels)

@jahsome
Copy link

jahsome commented Jan 8, 2022

Stumbled into a workaround thanks to a very unique combination of sheer laziness and force of stubborn will.

I just added a "staging" layer and slammed my entire context to copy from It appears to have the added benefit of standardizing to *nixy / paths from the get-go, and just copying in --from=ctx instead:

FROM scratch as ctx
WORKDIR /app
COPY . /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
COPY --from=ctx "app/src/*/*.csproj" "./"

I'm sure this is bloating my caches with unneeded builds though. I'm trying, but I can't figure out how to explicitly exclude the stage from caching (via Dockerfile at least).

@fadamsen
Copy link

fadamsen commented Feb 8, 2022

Is there anything we can do to get this looked at?

@Cjewett
Copy link

Cjewett commented May 1, 2023

Is there any hope if this issue being addressed?

@ghost
Copy link

ghost commented Jun 28, 2023

Hi all
This seems like a very strange issue that globbing does not work?
Is this fo for buildkit on windows only (via WSL)

The proposed work arounds above defeat the purpose of layer caching. in docker build?

image

@cabeaulac
Copy link

cabeaulac commented Jun 28, 2023 via email

@ghost
Copy link

ghost commented Jun 28, 2023

OK so its not a host issue.. its just globbing is not implemented in copy for buildkit

That is very strange to have feature parity missing like that.. especially when the legacy builder is about to be removed.

Who do we escalate this too because I have noticed buildkit issues have been open for years and nobody really doing anything here?

@andremarcondesteixeira
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature-parity Feature parity with classic builder status/needs-investigation
Projects
None yet
Development

No branches or pull requests