kaniko icon indicating copy to clipboard operation
kaniko copied to clipboard

ADD directive: Cannot copy file to a destination that has symlink

Open kennethzfeng opened this issue 4 years ago • 1 comments

Actual behavior kaniko failed to copy the downloaded file to the destination, and printed an error,

INFO[0022] Adding remote URL https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.3.1/grpc_health_probe-linux-amd64 to /bin/grpc_health_probe
INFO[0022] destination cannot be a symlink /bin
error building image: error building stage: failed to execute command: downloading remote source file: creating parent dir: destination cannot be a symlink

Expected behavior The download file should be placed under the /bin directory.

To Reproduce Steps to reproduce the behavior:

  1. Place the below Dockerfile in a directory
  2. Run the following command
docker run \
     -v $PWD:/workspace \
     gcr.io/kaniko-project/executor@sha256:fcccd2ab9f3892e33fc7f2e950c8e4fc665e7a4c66f6a9d70b300d7a2103592f \
     --dockerfile /workspace/Dockerfile \
     --context dir://. \
     --no-push

Additional Information

  • Dockerfile
FROM amazoncorretto:11.0.4 as BUILD

ARG GRPC_HEALTH_PROBE_VERSION=v0.3.1
RUN curl -O /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64
ADD https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 /bin/grpc_health_probe
  • Build Context - None
  • Kaniko Image (gcr.io/kaniko-project/executor@sha256:fcccd2ab9f3892e33fc7f2e950c8e4fc665e7a4c66f6a9d70b300d7a2103592f)

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
  • - [X]
Please check if this error is seen when you use --cache flag
  • - [ ]
Please check if your dockerfile is a multistage dockerfile
  • - [ ]

kennethzfeng avatar Oct 13 '21 17:10 kennethzfeng

To add to this - it's tricky because the symlinked destination is actually coming from a FROM layer that I don't have direct control over. I need to copy a config file in there, but can't, because of this bug / feature gap.

Is anyone aware of a workaround?

tdalbo92 avatar Apr 01 '24 21:04 tdalbo92