GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.23k stars 1.4k forks source link

Kaniko doesn't support symlinks in Dockerfile #3175

Open Kifok opened 1 month ago

Kifok commented 1 month ago

Actual behavior I've found out that kaniko doesn't support symlinks it's make issues like on screenshot below. telegram-cloud-document-2-5341563474990353752

Expected behavior In my approach, we need to build docker images without any changes in Dockerfile

To Reproduce Steps to reproduce the behavior: You should create dockerfile with symlinks like below

Additional Information

COPY --from=builder /app/dist /usr/share/nginx/html RUN rm /etc/nginx/conf.d/default.conf COPY ./nginx.conf /etc/nginx/conf.d

RUN chown -R nginx:nginx /var/cache/nginx && \ chown -R nginx:nginx /var/log/nginx && \ chown -R nginx:nginx /etc/nginx/conf.d && \ touch /var/run/nginx.pid && \ chown -R nginx:nginx /var/run/nginx.pid


 **Triage Notes for the Maintainers**
 <!-- πŸŽ‰πŸŽ‰πŸŽ‰ Thank you for an opening an issue !!! πŸŽ‰πŸŽ‰πŸŽ‰
We are doing our best to get to this. Please help us by helping us prioritize your issue by filling the section below -->

 | **Description** | **Yes/No** |
 |----------------|---------------|
 | Please check if this a new feature you are proposing        | <ul><li>- [ ] </li></ul>|
 | Please check if the build works in docker but not in kaniko | <ul><li>- [Yes ] </li></ul>| 
 | Please check if this error is seen when you use `--cache` flag | <ul><li>- [No ] </li></ul>|
 | Please check if your dockerfile is a multistage dockerfile | <ul><li>- [Yes ] </li></ul>| 
Kifok commented 1 month ago

Adding more information, this is build command i've used to build docker image docker run \ -v $PWD:/build \ gcr.io/kaniko-project/executor:debug \ --dockerfile=Dockerfile \ --tar-path /build/image.tar \ --no-push \ --context /build \ --destination myimage:1.2

Also if i build via gitlab-ci i get this kind of error:

Screenshot 2024-05-27 at 15 29 20

Build command for gitlab: /kaniko/executor --context ./ --destination ${IMAGE}:${IMAGE_TAG}

lordkekz commented 1 week ago

I think I'm missing some context on your issue. Which file exactly is a symlink in your container? I don't see any ln calls or anything else to indicate that there even is a symlink involved.

I'm facing a possibly related issue, I'm getting error building image: could not save file: copying ownership: chown /kaniko/1/<path>: no such file or directory which I suspect might be due to some symlink pointing to a non-existent file. I have confirmed that the file doesn't exist and doesn't need to exist.