Skip to content

Proposal: recursive .dockerignore files #20944

@c24w

Description

@c24w

I can't find anything which relates to this, but it would be useful if .dockerignore files could exist in any directory, defining paths relative to themselves (like .gitignore).

Example:

Working dir

.
├── add-dir
│   ├── add-me
│   ├── .dockerignore
│   └── ignore-me
├── add-me
├── Dockerfile
├── .dockerignore
└── ignore-me

Dockerfile

FROM alpine
WORKDIR /workdir
COPY . .
CMD ls -R

both .dockerignore files

ignore-me

Commands

$ docker build -t dockerignore-test .
$ docker run dockerignore-test
.:
Dockerfile
add-dir
add-me

./add-dir:
add-me
ignore-me # this file would not be inside the container

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/builderBuildkind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shinystatus/claimed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions