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

If dockerfile is ignored using double star pattern build fails to find dockerfile #40090

Open
kerhong opened this issue Oct 14, 2019 · 3 comments

Comments

@kerhong
Copy link

kerhong commented Oct 14, 2019

Description

If dockerfile is ignored in .dockerignore using a double star glob pattern (ex: **/docker, if dockerfile is a/b/docker/some.dockerfile) then, even if specified with --file parameter during build it will not be found.

Steps to reproduce the issue:

  1. Create a directory structure (or clone https://github.com/kerhong/dockerignore-dockerfile-difference)
├── .dockerignore
├── explicitly-ignored-dir
│   └── explicitly-ignored-dir.dockerfile
├── explicitly-ignored.dockerfile
├── glob-one-star-ignore
│   └── glob-one-star-ignore.dockerfile
├── glob-two-star-ignore
│   └── glob-two-star-ignore.dockerfile
├── ignored-by-glob.ignore.dockerfile

and .dockerignore

.dockerignore

explicitly-ignored.dockerfile
*.ignore.dockerfile
**/glob-two-star-ignore
explicitly-ignored-dir
glob-one-star-ignore/*
  1. Using docker build --file <FILE> . all dockerfiles are valid except glob-two-star-ignore/glob-two-star-ignore.dockerfile

Describe the results you received:
docker build --file glob-two-star-ignore/glob-two-star-ignore.dockerfile . fails with Error response from daemon: Cannot locate specified Dockerfile: glob-two-star-ignore/glob-two-star-ignore.dockerfile

Describe the results you expected:
docker build --file glob-two-star-ignore/glob-two-star-ignore.dockerfile . succeeds like all other dockerfiles in the example.

Output of docker version:

Client:
 Version:           19.03.3-ce
 API version:       1.40
 Go version:        go1.13.1
 Git commit:        a872fc2f86
 Built:             Wed Oct  9 02:28:51 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.3-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.1
  Git commit:       a872fc2f86
  Built:            Wed Oct  9 02:28:23 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.0.m
  GitCommit:        d50db0a42053864a270f648048f9a8b4f24eced3.m
 runc:
  Version:          1.0.0-rc9
  GitCommit:        d736ef14f0288d6993a1845745d6756cfc9ddd5a
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@luckydonald
Copy link

I think that is correct behavior. You excluded it so it doesn't get send to the docker machine.

You could include that file again with
!path/to/Dockerfile if I remember the ignore file syntax correctly.

@kerhong
Copy link
Author

kerhong commented Oct 24, 2019

@luckydonald I don't think this behavior is correct, because all other ways to ignore Dockerfile that I described can be built.

There is also https://github.com/moby/moby/blob/master/CHANGELOG.md#150-2015-02-10

Dockerfile and .dockerignore files can be themselves excluded as part of the .dockerignore file, thus preventing modifications to these files invalidating ADD or COPY instructions cache

@luckydonald
Copy link

Huh, indeed.

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

2 participants