GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.7k stars 1.43k forks source link

kaniko fails to build Dockerfile inside kubernetes pod but can build with docker run... #1830

Open bharath-krishna opened 2 years ago

bharath-krishna commented 2 years ago

Actual behavior

Expected behavior Expected to get output as below when I run kaniko with docker run command

docker run -it --rm -v `pwd`:/workspace gcr.io/kaniko-project/executor:v1.7.0-debug --dockerfile=Dockerfile --no-push
INFO[0000] Retrieving image manifest python:3.7.6-alpine3.11 
INFO[0000] Retrieving image python:3.7.6-alpine3.11 from registry index.docker.io 
.
.
.
OK: 102 MiB in 55 packages
INFO[0017] Taking snapshot of full filesystem...        
INFO[0019] Skipping push to container registry due to --no-push flag 

To Reproduce Steps to reproduce the behavior:

  1. Create a kubernetes pod with kaniko debug image and /busybox/sleep infinity command
  2. Switch to container terminal with kubectl exec command
  3. Create a Dockerfile in /workspace directory
  4. Run command executor --dockerfile=Dockerfile --no-push

Additional Information

doriandekoning commented 2 years ago

We have a similar issue (on 1.6.0, 1.7.0 and 1.8.1), since it has been quite a while did you find a solution to this problem (or is there another update maybe)?

bharath-krishna commented 2 years ago

It's been quite a while, and if I remember correctly, the solution we found out was not to change USER in Dockerfile frequently, I mean changing from APP user to ROOT user and back.

If there are multiple changes like this then Kaniko fails to build.

doriandekoning commented 2 years ago

Thanks for the reply! We did not do any user changes so that was a problem for us. When we switched to another base image (busybox -> debian) we did not encounter the problem anymore.