Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

ADD or COPY with symbolic link breaks image #942

@shortstories

Description

@shortstories

Actual behavior
Image is broken when there is a symbolic link at the destination when ADD or COPY

Expected behavior
build should succeed and sources should be in destination

To Reproduce

  1. create Dockerfile
FROM ubuntu
RUN mkdir -p /root/real && ln -sf /root/real /root/symlink
## cases
# case1: build success, but file path is wrong:  `/root/root/real/test-file`
COPY test-file /root/symlink/test-file 
# case2: image broken
COPY test-file /root/symlink/inner/test-file 
# case3: build fail
COPY test-dir/ /root/symlink 
# case4: image broken 
COPY test-dir/ /root/symlink/test-dir/ 
# case5: image broken
COPY test-dir/ /root/symlink/inner/test-dir/ 
  1. image build with kaniko
$ mkdir test-dir && echo "test" > test-file && cp test-file test-dir/test-dir-file
$ /kaniko/executor --destination=shortstories/kaniko-test:case1 -v=trace
  1. docker run
$ docker run --rm -it --entrypoint='/bin/bash' shortstories/kaniko-test:case4
Unable to find image 'shortstories/kaniko-test:case4' locally
test: Pulling from shortstories/kaniko-test
2746a4a261c9: Pull complete
4c1d20cdee96: Pull complete
0d3160e1d0de: Pull complete
c8e37668deea: Pull complete
ad9c552434bd: Pull complete
780db71f2ce6: Extracting [==================================================>]     257B/257B
docker: failed to register layer: Error processing tar file(exit status 1): mkdir /root/symlink: file exists.
See 'docker run --help'.
  • test images
    • shortstories/kaniko-test:case1
    • shortstories/kaniko-test:case2
    • shortstories/kaniko-test:case4
    • shortstories/kaniko-test:case5

Additional Information

  • Dockerfile
    • See To Reproduce
  • Build Context
    • See To Reproduce
  • Kaniko Image (fully qualified with digest)
    • gcr.io/kaniko-project/executor:v0.15.0 (digest: sha256:630f263d9123266b9f5420d9bc130e6a79306dbc312e5a7d35d922df391192bb)

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dockerfile-commandFor all bugs related to dockerfile file commandskind/bugSomething isn't workingpriority/p1Basic need feature compatibility with docker build. we should be working on this next.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions