Skip to content

Buildkit ignores .dockerignore in Git repository #2353

@phoenix-bjoern

Description

@phoenix-bjoern

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:

  1. export DOCKER_BUILDKIT=1
  2. docker build https://github.com/PHOENIX-MEDIA/buildkit-test.git
  3. docker run -ti --rm <image> sh
  4. 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:

  1. git clone https://github.com/PHOENIX-MEDIA/buildkit-test.git .
  2. docker build .
  3. docker run -ti --rm <image> sh
  4. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions