-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Kaniko fails to execute multiple builds in same container #2793
Comments
I was not able to reproduce this. Used "Kaniko version : v1.16.0" from debug image I used a slightly modified Dockerfile:
EDIT: Maybe it is caused by mem/disk space? |
I'm experiencing the same problem, reproducible like this:
|
@mama-wk Had similar issue, so running
that I am building with the custom executor with pre-installed aws cli, it fails with
Is this the expected behavior? Atleast for me it seems very strange I couldn't find any explanation as to why this happens. :( |
Hello after finding this issue here and trying a lot of things to find a generic fix for my case, I found what I think solves most my error cases. In my case this solved all the failing builds with the different dockerfiles of around 15 projects (not all were failing but the ones with dockerfiles with more stages were more prone to fail). My use case of kaniko is inside a jenkins pipeline that is using kubernetes plugin to run jobs inside kubernetes agent pods. Those agents have defined 1 single kaniko container and my need was to build the image twice with that single kaniko container, once as a tar to scan it with Trivy (a tool to scan containers) and after some quality checks are met use again the kaniko container to just build the image again and upload it to ECR. My solution was adding this to my first call of building the image as a tar: && rm -rf /kaniko/*[0-9]* && rm -rf /kaniko/Dockerfile && mkdir -p /workspace Call ending like this.
Not a huge kaniko user myself but found this /kaniko directory was filled with some files after the 1st execution as some people in this thread mentioned. those files were messing the next execution. Those commands after the 1st build remove those problematic files and second execution works as a charm. Hope this helps other people that find this issue. Thanks. |
Thanks a lot for your feedback ! |
Thanks for the workaround! This was really helpful. I would also appreciate it if there is a flag which does the thing. @ricardllop sorry for directly tagging you but we have similar environment, do you also stumble accross inconsistencies?
|
It was consistent for our environment, although we have shifted into using kaniko to build as tar --> scan the tar with trivy --> then crane to push the tar to ECR |
We have faced this issue as well, when trying to invoke Kaniko twice for building an Alpine image with different versions of Maven/Amazon Corretto. We downloaded/uncompressed/moved Maven files to the Maven home folder. It worked for the first execution, but failed when moving the files during the second execution because files were already present. IMHO the cleanup flag should endure that we get a clean slate between executions and that there are no leftovers from previous runs. |
Thanks @ricardllop , this helped me with reusing same kaniko container in jenkins pipeline, even if I've already used 11:31:22 + rm -rf /kaniko/0 /kaniko/1243507711 /kaniko/1267127570 /kaniko/1291417459 /kaniko/1811132102 /kaniko/2122718679 /kaniko/232121738 /kaniko/2419771487 /kaniko/2454894120 /kaniko/2528370616 /kaniko/2550122943 /kaniko/266100005 /kaniko/2765341715 /kaniko/2797314277 /kaniko/2823469896 /kaniko/3081883165 /kaniko/3082013316 /kaniko/3120064069 /kaniko/3237801189 /kaniko/3407385118 /kaniko/346726080 /kaniko/3472971071 /kaniko/3650347770 /kaniko/3699928372 /kaniko/4014459482 /kaniko/4095587153 /kaniko/4141075137 /kaniko/4176115670 /kaniko/452533812 /kaniko/575631331 /kaniko/70706009 /kaniko/71760931 '&&' rm -rf /kaniko/Dockerfile '&&' mkdir -p /workspace
11:31:22 rm: unrecognized option: p thank you! |
Actual behavior
Kaniko fails to execute sequential builds in the same container. After the first build, the second build fails to start the kaniko command to build the image.
Expected behavior
Kaniko should not fail during multiple image builds in same container.
To Reproduce
Steps to reproduce the behavior:
image gcr.io/kaniko-project/executor:debug
.Additional Information
image gcr.io/kaniko-project/executor:debug
Fix/Workaround
workspace
directory which makes it difficult for the next image build to execute image creation in the same container.The workaround was to:
mkdir -p /workspace
--cleanup
arg.rm -rf /kaniko/0
Expectation
/workspace
directory deletion after the execution of kaniko build command. something like--reuse-executor=true
rm -rf /kaniko/0
can be handled from--cleanup
flag itself.Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: