error setting metadata for a tmp file created in the copy local process

24 views Asked by At

I'm running a docker build on Ubuntu 23.10 on Docker version 24.0.5, build ced0996 and it's producing an empty (0 byte) .tmp.+rand file in the process then throwing an error that it cannot set the metadata for it when trying to copy it locally:

ERROR: failed to solve: error from receiver: error setting metadata for
build/.tmp.680872741: lchown build/.tmp.680872741: operation not permitted

My artifacts.Dockerfile looks like:

# use the build image as a transient container for the build
FROM release-build AS build

# build in the home folder
WORKDIR /home/project

# copy the assets and dependencies into the build images source directory
COPY build/ .

# build the component
#RUN make project 1>>build.txt 2>>build.txt

# copy the object, dependencies, and entire build to the local file system
FROM scratch
COPY --from=build /home/project /

The actual make is commented out while diagnosing this issue indicating that this tmp file is being created by docker. The build is being run like:

sudo cat artifacts.Dockerfile | docker build --no-cache --file - --output type=local,dest=build .

and the output looks like:

 => [internal] load build definition from Dockerfile                                      0.0s
 => => transferring dockerfile: 723B                                                      0.0s
 => [internal] load .dockerignore                                                         0.0s
 => => transferring context: 2B                                                           0.0s
 => [internal] load metadata for docker.io/library/release-build:latest                   0.0s
 => [build 1/3] FROM docker.io/library/release-build                                      0.0s
 => [internal] load build context                                                         0.0s
 => => transferring context: 26.09kB                                                      0.0s
 => CACHED [build 2/3] WORKDIR /home/project                                              0.0s
 => [build 3/3] COPY build/ .                                                             0.0s
 => [stage-1 1/1] COPY --from=build /home/project /                                       0.0s
 => ERROR exporting to client directory                                                   0.0s
 => => copying files 1.89kB                                                               0.0s
------
 > exporting to client directory:
------
ERROR: failed to solve: error from receiver: error setting metadata for build/.tmp.680872741:
lchown build/.tmp.680872741: operation not permitted

Type tmp file is not present before the build, but is present after the failure - i.e. it copied locally then the attributes failed. I've tried with and without sudo, I've tried adding --chown 1000:1000 (matches my local ids) to the final COPY, tried without the cat to docker cache bypass. It seems the COPY build/ . is where this 0-byte .tmp. file is being created as commenting that out avoids the file. I tried changing that COPY to just copy a single file in and that tmp file is still created.

I'm at a loss as to how to avoid this tmp file creation, or its copy, or the attribute error. Anyone have insights? Thanks.

0

There are 0 answers