Repository: GoogleContainerTools/kaniko

Issue #595: The .dockerignore file also matches between stages
Created: 2019-03-04T02:44:27Z
Actual behavior
The patterns in .dockerignore match not only in workdir but also when copying between stages.
Expected behavior
I expected kaniko to have the same semantics as in docker build.
The patterns should match only on initial import relative to /workdir/ not between stages relative to /.
To Reproduce
$ cat Dockerfile 
from busybox
run mkdir /foo/
run touch /foo/bar
run ls -l / /foo/

from busybox
copy --from=0 /foo/ /foo/
run ls -l / /foo/
$ cat .dockerignore 
/foo/
$ docker run --rm -v $PWD:/workspace gcr.io/kaniko-project/executor:v0.9.0 --no-push
[...]
INFO[0007] copy --from=0 /foo/ /foo/                    
INFO[0007] Taking snapshot of full filesystem...        
INFO[0007] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0007] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0007] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0007] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0007] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0008] No files were changed, appending empty layer to config. No layer added to image. 
INFO[0008] run ls -l / /foo/                            
INFO[0008] cmd: /bin/sh                                 
INFO[0008] args: [-c ls -l / /foo/]                     
ls: /foo/: No such file or directory

Trying the same with v0.7.0 or docker build works fine.

Duplicate issue #615: Multistage builds not copying files
Created: 2019-03-13T16:01:30Z
Actual behavior
Files that are generated in a stage do not get copied over in the next stages.
Expected behavior
Files should get copied over to the next stages
To Reproduce
Steps to reproduce the behavior:

Build a simple two-stage image

FROM python:3.5 AS builder
RUN pip install virtualenv
RUN virtualenv /venv -p python3

FROM python:3.5-slim
COPY --from=builder /venv /venv


Inspecting the resulting image, we notice there is no /venv. Also this output:

INFO[0117] Taking snapshot of full filesystem...        
INFO[0118] COPY --from=builder /venv /venv              
INFO[0119] Taking snapshot of full filesystem...        
INFO[0119] No files were changed, appending empty layer to config. No layer added to image. 

Additional Information

Runing this in GitLab using gcr.io/kaniko-project/executor:debug (tested sha256:642ef6209052ed2d96bfc20d2edc2803300ce3d858773629683b6d0903624777 and sha256:3c820e1112b24421d103582dbf27e7fca05b4eb335adaadca3d616d3d48689b9)
Works fine with Docker:

❯ cat Dockerfile2
FROM python:3.5 AS builder
RUN pip install virtualenv
RUN virtualenv /venv -p python3

FROM python:3.5-slim
COPY --from=builder /venv /venv

❯ docker build . -t test -f Dockerfile2
Sending build context to Docker daemon  547.8kB
Step 1/5 : FROM python:3.5 AS builder
...
Successfully built 05bc82648689
Successfully tagged test:latest

❯ docker run -it test:latest ls -als /venv
total 20
4 drwxr-xr-x 5 root root 4096 Mar 13 16:02 .
4 drwxr-xr-x 1 root root 4096 Mar 13 16:03 ..
4 drwxr-xr-x 2 root root 4096 Mar 13 15:29 bin
4 drwxr-xr-x 2 root root 4096 Mar 13 15:29 include
4 drwxr-xr-x 3 root root 4096 Mar 13 15:29 lib

Closing comment (2019-03-19T14:00:39Z): Closing as a dup of #595