-
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
Multistage build is causing deletion of files from kaniko run environment #450
Comments
please try this: the config files should be located in the kaniko/.docker folder, to perserve of deletion Explanation: due the multistage build, kaniko deletes the filesystem between the stages, the /root/.docker folder is not protected. Only if you use the /kaniko this configuration will be protected. If this (not) solves your issue, please post your result...
|
@miguelitoq76 yes, this is a working solution. thank you |
I'm not clear whether there is a bug here. Config for private registries should be located at When I created a random file (say at If there is an issue here with losing files please provide some repro steps. Thanks! |
Closing this as there are no updates. Feel free to reopen if there is still an issue |
I put the Kaniko I know one could work around it, as I described above, but why does Kaniko have this system destroying behavior?! I thought about running it before I put it in a container, but I saw that it needed |
I'm experiencing the same issue, Kaniko executer v1.5.1. /busybox is being deleted in multistage build |
The same for 1.6.0 |
The way that Kaniko seems to work is to use it's local filesystem, not a Go binaries (like This sort of solution (Kaniko destroying everything instead of restoring the original state on the second image) is less than optimal. |
Hey there, I'm still facing this issue. My docker config is deleted in the multistage build so the image cant be pushed at the end. Is there a way to add directories to the whitelist? EDIT: just had a quick look through the code and it seems that its currently only available when using kaniko as a library |
my dockerfile kinda looks like this: step 1: create docker config with auth in /root/.docker/config.json step2: run kaniko with a multistage dockerfile (we use this one):
when building this dockerfile with kaniko the /root/.docker/config.json is deleted at the end and cant be pushed to its destinations |
That has been our experience. With Docker Engine being forced out of Kubernetes, we've had to move our Jenkins server to a VM. It feels like a huge step backwards. I thought that Kaniko would fix that problem, but it looks like it doesn't have enough control to make multistage builds work. I'd rather run QEMU in a container and get Docker Engine building the container. |
Hello, I have the same issue and and I add/install what you need under /kaniko folder which is skipped to be deleted. |
@qalinn Yes, and that requires having a very specific structure to your images, and it must be used in every stage. If this could be hidden from the perspective of the Dockerfile, then that might work, but if it's not transparent (meaning that the same Dockerfile could be used in both Docker Engine and Kaniko), then it would force all parties (devs, QA and production environments) using a Dockerfile to exclusively use Kaniko, which can't be forced on them. |
Problem still exists. |
Hi, I'm also experiencing an issue. I'm building a Dockerfile with kaniko in GCP CloudBuild. Among other things I need to copy a config to another folder and replace one line there. For some reason after running these 2 commands, kaniko deletes the said file. So the file should be found in /tmp but it never persists. I also tried other directories and still have the same issue. |
@devopsinthecloud If you put things in the |
Nice in theory, however in my case my aws creds are written to /root/.aws/credentials and during the multistage build it appears this gets removed. If I put them in /kaniko/.aws/credentials it doesn't work. Also I noticed exporting my credentials doesn't work either. They show up in the environment but I get an authentication error to ECR error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "repoaddress:tagname": Post "repoaddress:tagname/blobs/uploads/": EOF |
A |
Actual behavior
Before executor is called in the runtime of kaniko the /root/.docker/config.json file is created to allow kaniko access to private registries.
When multistage build is executed before the image of next stage is downloaded kaniko make deletes the filesystem. After the deletion of the file system also the /root/.docker/config.json file is deleted. As consequence the image of the third stage cant be downloaded form private registry anymore. In the 2 stage builds, after both stages are processed the resulting image cant be pushed to private registry because of missing credentials.
This problem affects #407 and was not completely fixed with !192 MR #192
Expected behavior
Deleting of filesystem is not deleting files from kaniko runtime environment at all.
To Reproduce
Steps to reproduce the behavior:
Additional Information
Dockerfile:
FROM $CI_REGISTRY_IMAGE:test2 as pg
FROM $CI_REGISTRY_IMAGE:test1 as go
FROM $CI_REGISTRY_IMAGE:latest
Build with gitlab ci pipeline:
The text was updated successfully, but these errors were encountered: