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

Unable to copy file via hard link when using buildkit #4879

Closed
tmarsh-cloudian opened this issue Apr 25, 2024 · 2 comments
Closed

Unable to copy file via hard link when using buildkit #4879

tmarsh-cloudian opened this issue Apr 25, 2024 · 2 comments

Comments

@tmarsh-cloudian
Copy link

When I attempt to copy a file into a container via a hard link, I get an error about the build context.

Version:

$ docker --version
Docker version 24.0.9-2, build 293681613032e6d1a39cc88115847d3984195c24

The following script reproduces the issue for me:

#! /bin/bash

set -euxo pipefail

cd "$(mktemp -d)"

echo 123 > myfile
ln myfile mylink

cat <<EOF > Dockerfile
FROM gcr.io/distroless/static:nonroot
COPY mylink /tmp
EOF

docker build --no-cache .

Outputs:

++ mktemp -d
+ cd /tmp/tmp.TScXE0bdOw
+ echo 123
+ ln myfile mylink
+ cat
+ docker build --no-cache .
[+] Building 1.2s (5/6)                                    docker:default
 => [internal] load .dockerignore                                    0.0s
 => => transferring context: 2B                                      0.0s
 => [internal] load build definition from Dockerfile                 0.0s
 => => transferring dockerfile: 92B                                  0.0s
 => [internal] load metadata for gcr.io/distroless/static:nonroot    1.1s
 => ERROR [internal] load build context                              0.0s
 => => transferring context: 33B                                     0.0s
 => [1/2] FROM gcr.io/distroless/static:nonroot@sha256:e9ac71e2b8e2  0.0s
 => => resolve gcr.io/distroless/static:nonroot@sha256:e9ac71e2b8e2  0.0s
------
 > [internal] load build context:
------
ERROR: failed to solve: invalid link mylink to unknown path: "myfile"

When I disable buildkit, by replacing the last line of my script with

DOCKER_BUILDKIT=0 docker build --no-cache .

The container is built as expected, output:

++ mktemp -d
+ cd /tmp/tmp.fmYpyPbRpy
+ echo 123
+ ln myfile mylink
+ cat
+ DOCKER_BUILDKIT=0
+ docker build --no-cache .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  3.584kB
Step 1/2 : FROM gcr.io/distroless/static:nonroot
nonroot: Pulling from distroless/static
b2ce0e066077: Pull complete 
e8d9a567199d: Pull complete 
058cf3d8c2ba: Pull complete 
b6824ed73363: Pull complete 
7c12895b777b: Pull complete 
33e068de2649: Pull complete 
5664b15f108b: Pull complete 
27be814a09eb: Pull complete 
4aa0ea1413d3: Pull complete 
da7816fa955e: Pull complete 
9aee425378d2: Pull complete 
Digest: sha256:e9ac71e2b8e279a8372741b7a0293afda17650d926900233ec3a7b2b7c22a246
Status: Downloaded newer image for gcr.io/distroless/static:nonroot
 ---> 9104641e0242
Step 2/2 : COPY mylink /tmp
 ---> eacd493fa464
Successfully built eacd493fa464
@jedevc
Copy link
Member

jedevc commented Apr 25, 2024

I think this looks like a duplicate of #4831 - so closing this for now (if it's different, just shout, we can re-open! 🎉)

This should be fixed by #4870, which will be included in the upcoming v0.13.2 release: https://github.com/moby/buildkit/milestone/33

@jedevc jedevc closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
@tmarsh-cloudian
Copy link
Author

Yeah looks the same, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants