-
Notifications
You must be signed in to change notification settings - Fork 508
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
Buildkit ignores .dockerignore in Git repository #2353
Comments
Thanks for reporting @tonistiigi @tiborvass PTAL |
It is possible we could add a completely separate implementation of dockerignore that removes files on git clone and another one for tarball download but then that would be different from the legacy build(although unlikely to cause practical issues). If your usecase prefers removing files you can always just run |
@tonistiigi thanks for the insights. The reason why we used the build from remote sources (git) is that it can retrieve only the delta and therefore should be faster than cloning and then copying the whole files (could be several hundreds MBs). We didn't expect there would be any difference in behavior. |
see https://github.com/docker/cli/issues/2827 why it doesn't work for .dockerignore
see https://github.com/docker/cli/issues/2827 why it doesn't work for .dockerignore
Oh, the docs are clear, they just say the opposite: https://docs.docker.com/build/building/context/
Note how it explicitly says |
cc @dvdksn |
When using
docker build
with a Git repo as build context and DOCKER_BUILDKIT=1 the .dockerignore contents in the Git repo gets ignored and the files/directories get copied in the Docker image.When DOCKER_BUILDKIT env is not set, the ignored files/directories are correctly excluded and can't be found in the Docker image.
Steps to reproduce the issue:
export DOCKER_BUILDKIT=1
docker build https://github.com/PHOENIX-MEDIA/buildkit-test.git
docker run -ti --rm <image> sh
ls -la /var/www/html/
The files in https://github.com/PHOENIX-MEDIA/buildkit-test/blob/master/.dockerignore shouldn't be in the html folder.
You can repeat the steps with a clone of the repository on your local machine:
git clone https://github.com/PHOENIX-MEDIA/buildkit-test.git .
docker build .
docker run -ti --rm <image> sh
ls -la /var/www/html/
The folder only contains the
copy.me
file, which is the expected result according to the .dockerignore contents.I'm using Docker version 19.03.13, build 4484c46d9d on Centos7.
The text was updated successfully, but these errors were encountered: