Skip to content
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 directory copy fails #1110

Closed
tarvitz opened this issue Mar 6, 2020 · 10 comments
Closed

Multistage build directory copy fails #1110

tarvitz opened this issue Mar 6, 2020 · 10 comments

Comments

@tarvitz
Copy link

tarvitz commented Mar 6, 2020

Actual behavior
Multistage build fails.

#: Dockerfile
FROM python:3.6-alpine as part-one
RUN set -x \
    && python -m venv /venv

FROM python:3.6-alpine
COPY --from=part-one /venv /venv

The latest kaniko result build and output:

docker run --rm -w /build-app -v `pwd`:/build-app -v ${HOME}/.docker:/kaniko/.docker \
    --entrypoint "" gcr.io/kaniko-project/executor:latest /kaniko/executor -c . -f Dockerfile \
    --destination "test" \
    --no-push

Output:

# previous stages are cut
INFO[0011] args: [-c set -x     && python -m venv /venv] 
+ python -m venv /venv
INFO[0013] Taking snapshot of full filesystem...        
INFO[0013] Resolving paths                              
INFO[0014] Saving file /venv for later use              
INFO[0014] Deleting filesystem...                       
INFO[0014] Retrieving image manifest python:3.6-alpine  
INFO[0015] Retrieving image manifest python:3.6-alpine  
INFO[0016] Unpacking rootfs as cmd COPY --from=part-one /venv /venv requires it. 
INFO[0019] Taking snapshot of full filesystem...        
INFO[0019] Resolving paths                              
INFO[0020] COPY --from=part-one /venv /venv             
error building image: error building stage: failed to execute command: read /kaniko/0/venv/lib: is a directory

Expected behavior
Multistage build runs well.

Output with kaniko: gcr.io/kaniko-project/executor:v0.17.1

INFO[0012] args: [-c set -x     && python -m venv /venv] 
+ python -m venv /venv
INFO[0014] Taking snapshot of full filesystem...        
INFO[0015] Saving file /venv for later use              
INFO[0015] Deleting filesystem...                       
INFO[0015] Retrieving image manifest python:3.6-alpine  
INFO[0016] Retrieving image manifest python:3.6-alpine  
INFO[0018] Unpacking rootfs as cmd COPY --from=part-one /venv /venv requires it. 
INFO[0021] Taking snapshot of full filesystem...        
INFO[0022] COPY --from=part-one /venv /venv             
INFO[0022] Taking snapshot of files...                  
INFO[0022] Skipping push to container registry due to --no-push flag 

To Reproduce
Steps to reproduce the behavior:

  1. Use provided Dockerfile
  2. Try to build it by the latest kaniko

Additional Information
Dockerfile:

FROM python:3.6-alpine as part-one
RUN set -x \
    && python -m venv /venv

FROM python:3.6-alpine
COPY --from=part-one /venv /venv

Build context not required
Kaniko images:

  • ok: sha256:970d32fa1eb2827a1f216d0b1090c8a575f0a29eb0a786ebd6fa544a56946867 (gcr.io/kaniko-project/executor:v0.17.1)
  • failure: sha256:876c47402df7e62af4e12b907a872bd962d5d8d4c39372ace61e9931bd734af9 (gcr.io/kaniko-project/executor:latest)

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [ no ]
Please check if the build works in docker but not in kaniko
  • - [ yes ]
Please check if this error is seen when you use --cache flag
  • - [ n/a ]
Please check if your dockerfile is a multistage dockerfile
  • - [ yes ]
@tejal29
Copy link
Member

tejal29 commented Mar 7, 2020

Thanks @tarvitz .

I have this PR #1114 and #1113 which ended up fixing this

FROM python:3.6-alpine as part-one
RUN set -x \
    && python -m venv /venv

FROM python:3.6-alpine

Here i used the gcr.io/kaniko-project/executor:edge from latest master.

docker run  -v /usr/local/google/home/tejaldesai/.config/gcloud:/root/.config/gcloud -v /usr/local/google/home/tejaldesai/workspace/kaniko/integration:/workspace gcr.io/kaniko-project/executor:edge -f dockerfiles/Dockerfile1 --context=dir://workspace --destination=gcr.io/tejal-test/test_1110 --no-push --tarPath image.tar
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine 
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine 
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine 
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine 
INFO[0000] Retrieving image manifest python:3.6-alpine  
INFO[0001] Retrieving image manifest python:3.6-alpine  
INFO[0001] Retrieving image manifest python:3.6-alpine  
INFO[0002] Retrieving image manifest python:3.6-alpine  
INFO[0003] Built cross stage deps: map[0:[/venv]]       
INFO[0003] Retrieving image manifest python:3.6-alpine  
INFO[0003] Retrieving image manifest python:3.6-alpine  
INFO[0004] Unpacking rootfs as cmd RUN set -x     && python -m venv /venv requires it. 
INFO[0006] Taking snapshot of full filesystem...        
INFO[0006] Resolving paths                              
INFO[0007] RUN set -x     && python -m venv /venv       
INFO[0007] cmd: /bin/sh                                 
INFO[0007] args: [-c set -x     && python -m venv /venv] 
+ python -m venv /venv
INFO[0009] Taking snapshot of full filesystem...        
INFO[0009] Resolving paths                              
INFO[0010] Saving file /venv for later use              
INFO[0010] Deleting filesystem...                       
INFO[0011] Retrieving image manifest python:3.6-alpine  
INFO[0011] Retrieving image manifest python:3.6-alpine  
INFO[0012] Unpacking rootfs as cmd COPY --from=part-one /venv /venv requires it. 
INFO[0014] Taking snapshot of full filesystem...        
INFO[0014] Resolving paths                              
INFO[0015] COPY --from=part-one /venv /venv             
INFO[0015] Resolving paths                              
INFO[0015] Taking snapshot of files...    

@tejal29
Copy link
Member

tejal29 commented Mar 7, 2020

Can you use the latest image?

gcr.io/kaniko-project/executor:edge
gcr.io/kaniko-project/executor:edge-debug
gcr.io/kaniko-project/warmer:edge

@tarvitz
Copy link
Author

tarvitz commented Mar 7, 2020

Checked with executor:edge, here's result:

Unable to find image 'gcr.io/kaniko-project/executor:edge' locally
edge: Pulling from kaniko-project/executor
0a808f4ece2c: Pull complete
2281caba317a: Pull complete
a9a25b68dfd8: Pull complete
83da15a9ffd7: Pull complete
b1d29b7bd0d6: Pull complete
1d33a19aafcc: Pull complete
115a4b33d86a: Pull complete
90d698384a66: Pull complete
Digest: sha256:df865f7143e8035da29687a53c16e5f4c2d1187dff688d7c9b57f4d4a389b64f
Status: Downloaded newer image for gcr.io/kaniko-project/executor:edge
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine
INFO[0000] Resolved base name python:3.6-alpine to python:3.6-alpine
INFO[0000] Retrieving image manifest python:3.6-alpine
INFO[0001] Retrieving image manifest python:3.6-alpine
INFO[0003] Retrieving image manifest python:3.6-alpine
INFO[0004] Retrieving image manifest python:3.6-alpine
INFO[0005] Built cross stage deps: map[0:[/venv]]
INFO[0005] Retrieving image manifest python:3.6-alpine
INFO[0006] Retrieving image manifest python:3.6-alpine
INFO[0007] Unpacking rootfs as cmd RUN set -x     && python -m venv /venv requires it.
INFO[0011] Taking snapshot of full filesystem...
INFO[0011] Resolving paths
INFO[0012] RUN set -x     && python -m venv /venv
INFO[0012] cmd: /bin/sh
INFO[0012] args: [-c set -x     && python -m venv /venv]
+ python -m venv /venv
INFO[0014] Taking snapshot of full filesystem...
INFO[0014] Resolving paths
INFO[0015] Saving file /venv for later use
INFO[0015] Deleting filesystem...
INFO[0015] Retrieving image manifest python:3.6-alpine
INFO[0016] Retrieving image manifest python:3.6-alpine
INFO[0017] Unpacking rootfs as cmd COPY --from=part-one /venv /venv requires it.
INFO[0021] Taking snapshot of full filesystem...
INFO[0021] Resolving paths
INFO[0022] COPY --from=part-one /venv /venv
INFO[0022] Resolving paths
INFO[0022] Taking snapshot of files...
INFO[0022] Skipping push to container registry due to --no-push flag

Dockerfile is the same.
Thanks @tejal29. It seems everything is fine now.

@joscarras
Copy link

@tejal29 I just tried the latest version you posted above (not including the warmer) and I am still getting a similar error

error building image: error building stage: failed to execute command: copying dir: mkdir /usr/local/zeek-3.1.0/lib/zeekctl: not a directory

I was able to resolve the issue by using gcr.io/kaniko-project/executor:debug-v0.17.1

@Nainterceptor
Copy link

Hello,

I'm adding some noise to this thread to find this issue via Google if somebody else have an issue in their CI/CD. So, sorry if my comment is not relevant for the issue resolution.

This issue cause a failure in many of our gitlab CD, we've switched to debug-v0.17.1 too, solving the issue. I guess that gitlab documentation should not recommand to configure on :debug tag :/

As a reference, our DockerFile, and our .gitlab-ci.yml in version 1.4.5 are affected by this issue, and this project is opensource.

Here, we are doing an npm install (yes, nodeJS project here, sorry), then we copy node_modules from the first stage to the second.
Copy is failing, but the CI step pass.
So, our issue is visible on runtime; while some files are not well copied, and some imports are failing. I guess that the copy partially works.

Best regards,
Gaël

@sereinity
Copy link

For me v0.19.0 has fixed the issue.

@tarvitz
Copy link
Author

tarvitz commented Mar 19, 2020

I've updated back to gcr.io/kaniko-project/executor:debug works fine with copying virtual environment directory of python (like in the example above).

@tejal29 tejal29 closed this as completed Mar 19, 2020
@dmilan77
Copy link

dmilan77 commented May 22, 2020

I just tested with gcr.io/kaniko-project/executor:debug

#: Dockerfile
FROM python:3.7.7-slim-buster as part-one
RUN set -x \
    && python -m venv /venv
RUN ls -l /venv

FROM python:3.7.7-slim-buster
COPY --from=part-one /venv /venv
RUN ls -l /venv

It's failing.

INFO[0016] args: [-c ls -l /venv]
ls: cannot access '/venv': No such file or directory
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 2

@mepunit
Copy link

mepunit commented Feb 24, 2022

Is it resolved?

I am still facing this issue.

@tarvitz
Copy link
Author

tarvitz commented Mar 2, 2022

Yes, the latest version of Kaniko works fine against the problem I've reported (I've just taken a look if builds are being built and they're fine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants