docker / docker/buildx

Support configuring `.dockerignore` path + support with remote contexts

Open
#3,169 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement status/triage
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 Dockerfile default to another filename (presently only supported via different sub-directories or slightly different --file input?)
  • Use the .dockerignore (which would be applied prior to using a shallow git clone as 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).

Related:

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.