Support configuring `.dockerignore` path + support with remote contexts
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
Description
Better support a git repo as remote context would be ideal with the ability to:
- Adjust the implicit
Dockerfiledefault to another filename (presently only supported via different sub-directories or slightly different--fileinput?) - Use the
.dockerignore(which would be applied prior to using a shallowgit cloneas build context?)
Current situation:
# Git URL context => Clones repo into a build context (local or repo `.dockerignore` is not applied)
# `--file` option provides HTTPS URL to select different Dockerfile variant
docker build \
--tag localhost/project-name:branch-or-tag \
--file https://raw.githubusercontent.com/user/repo/branch-or-tag/Dockerfile.alpine \
https://github.com/user/repo.sh.git#branch-or-tag
Proposed:
# --ignore should technically not be required to use `.dockerignore`
# from the remote context unless choosing to opt-out via `/dev/null`?
docker build \
--tag localhost/project-name:branch-or-tag \
--file context://Dockerfile.alpine \
--ignore context://.dockerignore \
https://github.com/user/repo.sh.git#branch-or-tag
EDIT(Dec 2025): Apparently --file Dockerfile.alpine works now relative to the remote context. I'm lacking information regarding my prior notes above for what happened without that. I know that with a local context that --file is not relative to the build context, so local vs remote contexts do differ there at least for --file.
Additional reference
Remote build contexts and Dockerfile (either implicit via remote context, or explicit via separate --file arg) are supported but not remote .dockerignore files (or even custom path locally).
- When looking into using remote contexts and a non-default
Dockerfilefile name, I was curious if I could perform a build with a singledocker buildcommand and references to a repo on Github, but noticed the larger image from lack of.dockerignorebeing applied to the build context (which I later noticed is also the case if this file exists locally). - The official docs still imply
.dockerignorewould be supported when it exists in the build context root, but is incorrect and needs to update the docs. - Additional build-context args are supported via CLI, but not one for overriding the default via path value instead of hard-coded filename patterns?
Related:
- https://github.com/docker/buildx/issues/2353#issuecomment-2018378945 (
.dockerignoredoesn't work for remote build contexts, even when it exists locally) - https://github.com/docker/buildx/issues/3121#issuecomment-2853151812 (original comment of mine as motivation for feature request)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the docker build/buildx handling for remote Git contexts and the --file, --ignore, and --build-context entry points; the payload names no source files or tests. Compare the behavior described in related issues and the Docker documentation. Done means a remote context can select a custom Dockerfile and apply a chosen .dockerignore path, with documentation matching the implemented behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, git, go
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100