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

Inconsistent .dockerignore file copy behavior with **/someDir/ pattern #1396

Closed
rcollette opened this issue Aug 25, 2020 · 2 comments
Closed

Comments

@rcollette
Copy link

Actual behavior
Directories listed in .dockerignore via **/someDir/ pattern are initially excluded from copying but files within those directories are created.

INFO[0005] WORKDIR /build                               
INFO[0005] cmd: workdir                                 
INFO[0005] Changed working directory to /build          
INFO[0005] Creating directory /build                    
TRAC[0005] Resolving paths [/build]                     
INFO[0005] Taking snapshot of files...                  
DEBU[0005] Taking snapshot of files [/build /]          
DEBU[0005] Resolved . to .                              
DEBU[0005] Resolved . to .                              
DEBU[0005] Using files from context: [/workspace]       
INFO[0005] COPY . .                                     
DEBU[0005] Resolved . to .                              
DEBU[0005] Resolved . to .                              
TRAC[0005] Updating destination path from /build/ to /build due to symlink 
DEBU[0005] Getting files and contents at root /workspace/ for /workspace 
TRAC[0005] Creating directory /build                    
DEBU[0005] Skipping excluded path: .dockerignore        
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Copying file /workspace/Dockerfile to /build/Dockerfile 
DEBU[0005] Skipping excluded path: bin                  
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Copying file /workspace/bin/dummy.txt to /build/bin/dummy.txt 
TRAC[0005] baseDir /build/bin for file /build/bin/dummy.txt does not exist. Creating. 
DEBU[0005] Copying file /workspace/kaniko-build.sh to /build/kaniko-build.sh 
DEBU[0005] Skipping excluded path: obj                  
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Copying file /workspace/obj/dummy.txt to /build/obj/dummy.txt 
TRAC[0005] baseDir /build/obj for file /build/obj/dummy.txt does not exist. Creating. 
DEBU[0005] Copying file /workspace/root.txt to /build/root.txt 
TRAC[0005] Creating directory /build/subfolder          
DEBU[0005] Skipping excluded path: subfolder/bin        
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Skipping excluded path: subfolder/bin/dummy.txt 
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Skipping excluded path: subfolder/obj        
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
TRAC[0005] Creating directory /build/subfolder/subfolder2 
DEBU[0005] Skipping excluded path: subfolder/subfolder2/bin 
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Copying file /workspace/subfolder/subfolder2/bin/dummy.txt to /build/subfolder/subfolder2/bin/dummy.txt 
TRAC[0005] baseDir /build/subfolder/subfolder2/bin for file /build/subfolder/subfolder2/bin/dummy.txt does not exist. Creating. 
DEBU[0005] Skipping excluded path: subfolder/subfolder2/obj 
DEBU[0005] /workspace/ found in .dockerignore, ignoring 
DEBU[0005] Copying file /workspace/subfolder/subfolder2/obj/dummy.txt to /build/subfolder/subfolder2/obj/dummy.txt 
TRAC[0005] baseDir /build/subfolder/subfolder2/obj for file /build/subfolder/subfolder2/obj/dummy.txt does not exist. Creating. 
TRAC[0005] Resolving paths [/build /build/Dockerfile /build/bin/dummy.txt /build/kaniko-build.sh /build/obj/dummy.txt /build/root.txt /build/subfolder /build/subfolder/subfolder2 /build/subfolder/subfolder2/bin/dummy.txt /build/subfolder/subfolder2/obj/dummy.txt] 
INFO[0005] Taking snapshot of files...                  
DEBU[0005] Taking snapshot of files [/build/subfolder /build/subfolder/subfolder2/bin/dummy.txt /build/subfolder/subfolder2/bin /build/bin/dummy.txt /build/Dockerfile /build/bin /build/obj/dummy.txt /build/root.txt /build/subfolder/subfolder2 /build/subfolder/subfolder2/obj/dummy.txt /build /build/obj /build/kaniko-build.sh /build/subfolder/subfolder2/obj /] 

Expected behavior
Current docker behavior is that an excluded directory does not have any of its contents copied.

To Reproduce

  1. Unzip attached project
    kaniko-dockerignore-issue.zip
  2. Go to root of attached project
  3. run ./kaniko-build.sh

Additional Information

  • Dockerfile
FROM alpine
WORKDIR /build
COPY . .
  • .dockerignore
**/bin/
**/obj/
DOCKERFILE
.dockerignore
  • Build Context
    image

  • Kaniko Image
    gcr.io/kaniko-project/executor:debug
    sha256:0f27b0674797b56db08010dff799c8926c4e9816454ca56cc7844df228c53485

  • Execution command

#!/bin/bash
docker run -it --rm \
        -v `pwd`:/workspace \
        gcr.io/kaniko-project/executor:debug \
        --dockerfile "Dockerfile" \
        --skip-unused-stages \
        --no-push \
        --verbosity=trace \
        --context=/workspace

.net core builds fail with an error due to user machine specific paths existing in files in those subfolders which do not existing in the .net core docker image mcr.microsoft.com/dotnet/core/sdk:2.2-alpine :

/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(208,5): error MSB4018: The "ResolvePackageAssets" task failed unexpectedly. 
/usr/share/dotnet/sdk/2.2.207/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(208,5): error MSB4018: NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder '/usr/local/share/dotnet/sdk/NuGetFallbackFolder'. 

In an actual application build, if all obj and bin folders are deleted from the project before running the build, no error results.

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
@tscni
Copy link
Contributor

tscni commented Sep 21, 2020

This is a bug in moby, see: moby/moby#41433

@aaron-prindle
Copy link
Collaborator

The referenced issue is fixed now upstream - moby/moby#41433. Closing as fixed

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

No branches or pull requests

3 participants