Closed thesayyn closed 2 days ago
I can reproduce the problem with --build-context
directory when it is mounted readonly. But the error is
ERROR: oci-layout reference "oci-layout://out2" could not be resolved: could not lock<dir>/index.json.lock: open <dir>/index.json.lock: read-only file system
Because it tries to create a file lock. Maybe you are on a system that doesn't support file locks, so you don't get that error. If I suppress error with file locks and don't have ingest
directory in my build context then I do get the error with that path as well. If you don't get an issue with file locks, then the workaround is to just make sure that an empty ingest directory already exists in the build-context directory.
then the workaround is to just make sure that an empty ingest directory already exists in the build-context directory.
i see that could be useful as a workaround, makes sense to create that folder when creating the oci-layout, i'll look into that but it would be great if this was fixed here.
Maybe you are on a system that doesn't support file locks
oh the reason i don't get the index.json.lock
issue is because i use a digest (to workaround) so that codepath is never hit. right here https://github.com/docker/buildx/blob/746eadd16e461ac1a961bb22e7fea8f1d05da88f/build/opt.go#L508
Thank you @tonistiigi, i can confirm that creating ingest
and index.json.lock
works as a workaround.
The lock side of this has been fixed in buildx v0.18.0 , the "ingest" side will need to wait for containerd libs update.
backport to containerd 1.7.x can be tracked at https://github.com/containerd/containerd/pull/10913
Looks like containerd v1.7 should have a backport and any versions beyond would have the fixes relaated to this time. Closing this issue. @thesayyn LMK if we need to re-open this
Contributing guidelines
I've found a bug and checked that ...
Description
Currently when attaching an oci-layout context to buildx, it wants to create some lock/ingest files within the target directory even though those files are not used in an meaningful way in this instance as far as in can see.
Here it wants to create
index.json.lock
if the digest is not providedhttps://github.com/docker/buildx/blob/746eadd16e461ac1a961bb22e7fea8f1d05da88f/build/opt.go#L509
And here if you provide a tag.
https://github.com/docker/buildx/blob/746eadd16e461ac1a961bb22e7fea8f1d05da88f/build/opt.go#L514
Context:
I am trying to build a Bazel ruleset to allow running buildx under Bazel, and to attach contexts to buildx so it can be copied into the resulting container, however, as a accidental write prevention measure, Bazel marks artifacts from other build rules as readonly which is where buildx fails because it assumes the stores to be writeable even though it does not need them to be writable in this instance.
Expected behaviour
I'd expect the oci-layout store to not create these ingestion/lock files eagerly.
Actual behaviour
oci-layout store creates ingest/lock files eagerly preventing the directories to be marked readonly.
Buildx version
v0.17.1
Docker info
No response
Builders list
Configuration
Build logs
Additional info
FWIW, i filed this issue in containerd repo https://github.com/containerd/containerd/issues/10885 as one of the offending library seems to be coming from there.