fix rootfs after execute '/kaniko/executor xxx --cleanup' #2776
Labels
area/multi-stage builds
issues related to kaniko multi-stage builds
issue/missing-files
kind/feature-request
priority/p1
Basic need feature compatibility with docker build. we should be working on this next.
Actual behavior
I have build an custom image since I need git and other commands during build stage, I found that after execute '/kaniko/executor xxx --cleanup' to build multi stages image, some folders of rootfs disappeared.
Expected behavior
Is it doable to have a option like '--backup' to backup rootfs before executing the '/kaniko/executor xxx --cleanup', and restore the rootfs when build is finished?
To Reproduce
In my custom kaniko executor image(base on debian 11 and kaniko v1.15.0).
I found that after execute '/kaniko/executor xxx --cleanup' to build multi stages image, some folders of rootfs disappeared.
before:
/workspace # ls -l / total 92 drwxr-xr-x 1 root root 4096 Aug 3 2022 bin drwxr-xr-x 2 root root 4096 Jun 30 2022 boot drwxr-xr-x 5 root root 360 Sep 27 08:10 dev drwxr-xr-x 1 root root 4096 Sep 27 08:10 etc drwxr-xr-x 2 root root 4096 Jun 30 2022 home drwxrwxrwx 1 root root 4096 Aug 29 21:49 kaniko drwxr-xr-x 2 root root 12288 Sep 27 08:10 kaniko_bin drwxr-xr-x 1 root root 4096 Aug 1 2022 lib drwxr-xr-x 2 root root 4096 Aug 1 2022 lib64 drwxr-xr-x 2 root root 4096 Aug 1 2022 media drwxr-xr-x 2 root root 4096 Aug 1 2022 mnt drwxr-xr-x 2 root root 4096 Aug 1 2022 opt dr-xr-xr-x 235 root root 0 Sep 27 08:10 proc drwx------ 1 root root 4096 Sep 27 08:10 root drwxr-xr-x 3 root root 4096 Aug 1 2022 run drwxr-xr-x 1 root root 4096 Aug 3 2022 sbin drwxr-xr-x 2 root root 4096 Aug 1 2022 srv dr-xr-xr-x 13 root root 0 Sep 27 08:10 sys drwxrwxrwt 1 root root 4096 Sep 27 07:47 tmp drwxr-xr-x 1 root root 4096 Aug 1 2022 usr drwxr-xr-x 1 root root 4096 Aug 1 2022 var drwxr-xr-x 7 root root 224 Sep 27 07:47 workspace
after:
/workspace # ls -l / total 44 drwxr-xr-x 5 0 0 360 Sep 27 07:49 dev drwxr-xr-x 1 0 0 4096 Sep 27 07:57 etc drwxrwxrwx 1 0 0 4096 Sep 27 07:57 kaniko drwxr-xr-x 2 0 0 12288 Sep 27 07:49 kaniko_bin dr-xr-xr-x 229 0 0 0 Sep 27 07:49 proc dr-xr-xr-x 13 0 0 0 Sep 27 07:49 sys drwxrwxrwt 1 0 0 4096 Sep 27 07:57 tmp drwxr-xr-x 1 0 0 4096 Sep 27 07:57 var drwxr-xr-x 17 0 0 544 Sep 26 10:57 workspace
Even I moved the 'git' command to '/kaniko_bin/', I still got below errors, but the 'patch' command still works. I think it's because 'patch' command is an binary command from kaniko image, it has no external dependency. But for 'git' command, it relies on some dependencies under rootfs.
Since the '/etc/passwd' is also deleted by kaniko, I can not enter the kaniko container, so I can not do next build with this kaniko container.
I know kaniko will extract the files of base image in Dockerfile to current container's rootfs, if I used ADD or COPY in Dockerfile.
Is it doable to have a option like '--backup' to backup rootfs before executing the '/kaniko/executor xxx --cleanup', and restore the rootfs when build is finished?
Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: