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

cli with buildkit will ignore dockerignore's check #1938

Open
tao12345666333 opened this issue Jun 11, 2019 · 5 comments · May be fixed by #1939
Open

cli with buildkit will ignore dockerignore's check #1938

tao12345666333 opened this issue Jun 11, 2019 · 5 comments · May be fixed by #1939

Comments

@tao12345666333
Copy link
Contributor

Description
docker CLI with builkit enabled will ignore .dockerignore file's read errors.

Steps to reproduce the issue:

(MoeLove) ➜  x cat Dockerfile 
FROM scratch

COPY foo foo
COPY bar bar
(MoeLove) ➜  x ls 
bar  Dockerfile  foo
(MoeLove) ➜  x cat Dockerfile 
FROM scratch

COPY foo foo
COPY bar bar
(MoeLove) ➜  x ls -al .dockerignore 
----------. 1 tao tao 4 6月  12 02:10 .dockerignore
(MoeLove) ➜  x cat .dockerignore           
cat: .dockerignore: Permission denied
(MoeLove) ➜  x whoami
tao
(MoeLove) ➜  x docker build --no-cache -t local/ignore .
[+] Building 0.1s (6/6) FINISHED                                                                                 
 => [internal] load .dockerignore                                                                           0.0s
 => => transferring context: 91B                                                                            0.0s
 => [internal] load build definition from Dockerfile                                                        0.0s
 => => transferring dockerfile: 95B                                                                         0.0s
 => [internal] load build context                                                                           0.0s
 => => transferring context: 162B                                                                           0.0s
 => [1/2] COPY foo foo                                                                                      0.0s
 => [2/2] COPY bar bar                                                                                      0.0s
 => exporting to image                                                                                      0.0s
 => => exporting layers                                                                                     0.0s
 => => writing image sha256:5ae5f1e9c56ee852af6a47c0aa4fe78fba3853e720171047617e8b022f06f456                0.0s
 => => naming to docker.io/local/ignore                                                                     0.0s

Describe the results you received:

Build image successfully.

Describe the results you expected:

Build image failed.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

(MoeLove) ➜  x docker version                                                                                    
Client: Docker Engine - Community
 Version:           0.0.0-20190607210243-b93f571b01
 API version:       1.40   
 Go version:        go1.12.5 
 Git commit:        b93f571b01
 Built:             Sat Jun  8 07:31:22 2019
 OS/Arch:           linux/amd64
 Experimental:      true

Output of docker info:

(paste your output here)

Additional environment details (AWS, VirtualBox, physical, etc.):
physical

@tiborvass
Copy link
Collaborator

@tao12345666333 i'm curious to know what the usecase is for relying on the failure.

@thaJeztah
Copy link
Member

@tiborvass the problem looks to be that a user has a .dockerignore, but the CLI doesn't have permissions to read it, and then continues the build without using the .dockerignore instead of failing the build

@tao12345666333
Copy link
Contributor Author

yep. when I build image without buildkit enabled, it will failed and return permission denied.

@tonistiigi
Copy link
Member

I believe this is very inconsistent in old builder. Files in context ignores permission error and .dockerignore does not. So I guess this is completely accidental behavior. Buildkit standardizes this and uses the same code for all the files without exceptions.

@tao12345666333
Copy link
Contributor Author

If this is expected behavior, then I can close this issue, thank you very much!

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

Successfully merging a pull request may close this issue.

5 participants