GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.66k stars 1.42k forks source link

Files copied incorrectly between multistage build #2098

Open calebwoofenden opened 2 years ago

calebwoofenden commented 2 years ago

Actual behavior A clear and concise description of what the bug is.

I have a multi-stage Dockerfile. The first stage, package_installer, installs Poetry and then installs Python packages with Poetry. The second, primary stage copies files from this stage:

COPY --from=package_installer /usr/local/lib/python3.7/site-packages/ /usr/local/lib/python3.7/site-packages/
COPY --from=package_installer /usr/local/bin/ /usr/local/bin/

When running a container from the image built by Kaniko using this Dockerfile, I run into strange Python errors. I used container-diff to compare this image to one created from the same Dockerfile with docker build and found that an enormous amount of files in /usr/local/lib and /usr/local/bin are changed. Most notably, every .pyc file in Python's site-packages is noted as changed.

Additionally, the image from the same Dockerfile built via Kaniko is about 15% larger than the one built via docker build.

Expected behavior A clear and concise description of what you expected to happen.

The image should be the same whether it's built with Kaniko or docker build.

To Reproduce Steps to reproduce the behavior:

  1. Create a Dockerfile with Python installed that installs Poetry and then installs some packages with Poetry
  2. Make it multi-stage and copy the above COPY commands in the second stage, being sure to change to the appropriate Python version

Additional Information

henricook commented 1 year ago

This is going to be very hard for anyone to work on if they have to come up with the reproduction case themselves. If you'd like it fixing I suggest you provide the minimal dockerfiles to recreate the problem here.