Building devcontainers does not use .dockerignore file next to the Dockerfile.

Open
#969 7 comments 9 reactions 1 assignee View on GitHub

@chrmarti is already working on this.

Since Mar 28, 2025.

Assessment

This issue has not been assessed yet.

Description

bug

Hi, is it possible that the .dockerignore file next to the Dockerfile is not being used to ignore files in the build context?

I used to think only the .dockerignore file in the root of the Docker build context was used and I know that it is not possible to specify another .dockerignore file using command line arguments (e.g. -i path/to/.dockerignore).
Then I read about this file naming workaround: Filename and location.

This works fine when I use docker compose build, docker buildx build, and docker buildx bake.
However, opening in a container, this Dockerfile.dockerignore next to my Dockerfile is not being used, while the one in the root of my context is working.

Dominant language
TypeScript
Stars
3k
Forks
461
Avg merge
18m
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from devcontainers/cli

All issues in devcontainers/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.