docker / docker/buildx

Symlinks are not handled correctly when BUILDKIT is enabled

Open
#611 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/dockerfile status/needs-investigation
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

Here's a minimal example to reproduce this problem

mkdir -p other_dir/sub_dir/{a,b}
ln -s other_dir/sub_dir
echo a > sub_dir/a/file
echo b > sub_dir/b/file

The directory structure is:

$ tree
.
├── Dockerfile
├── other_dir
│   └── sub_dir
│       ├── a
│       │   └── file
│       └── b
│           └── file
└── sub_dir -> other_dir/sub_dir

Dockerfile:

FROM alpine

COPY sub_dir/a /opt/a
COPY sub_dir/b /opt/b

RUN cat /opt/a/file
RUN cat /opt/b/file

DOCKER_BUILDKIT=0 docker build . -t dummy builds successfully, while DOCKER_BUILDKIT=1 produces the following error:

$ DOCKER_BUILDKIT=1 docker build . -t dummy
[+] Building 0.1s (7/9)
 => [internal] load build definition from Dockerfile                                                                        0.0s
 => => transferring dockerfile: 43B                                                                                         0.0s
 => [internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 2B                                                                                             0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                            0.0s
 => [1/5] FROM docker.io/library/alpine                                                                                     0.0s
 => [internal] load build context                                                                                           0.0s
 => => transferring context: 197B                                                                                           0.0s
 => CACHED [2/5] COPY sub_dir/a /opt/a                                                                                      0.0s
 => ERROR [3/5] COPY sub_dir/b /opt/b                                                                                       0.0s
------
 > [3/5] COPY sub_dir/b /opt/b:
------
failed to compute cache key: "/sub_dir/b" not found: not found

I run this on OSX with Docker version 20.10.6, build 370c289

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the listed directory tree and Dockerfile, comparing DOCKER_BUILDKIT=0 and DOCKER_BUILDKIT=1. Start by tracing the BuildKit path for the two COPY commands; done means both symlinked paths copy successfully and the Dockerfile builds with BuildKit enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.