I have done the following
Steps to reproduce
- Create a new directory somewhere.
- Create some dummy files:
mkdir -p foo/bar
touch foo/.gitkeep foo/bar/.gitkeep
- Create a
.dockerignore:
/foo/*
!/foo/.gitkeep
/foo/bar/*
!/foo/bar/.gitkeep
- Create a
Dockerfile:
- Attempt a build with
container build.
Problem description
.dockerignore resolution differs slightly between Docker standard and container build, especially when resolving (un)ignored paths. The provided sample files emit the following error upon building:
container build
[+] Building 0.1s (3/4)
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 58B
=> [internal] load .dockerignore
=> => transferring context: 91
=> ERROR [internal] load build context
=> => transferring context: 142B
------
> [internal] load build context:
------
Error: unknown: "failed to solve: changes out of order: "foo/bar/.gitkeep" "foo/.gitkeep""
This causes problems with, e.g., the default Rails .dockerignore configuration as generated by rails new and it leverages this layering to include/exclude certain subpaths while preserving .keeps.
Environment
- OS: macOS 26.5.1 (25F80)
- Xcode: 26.5 (17F42)
- Container: CLI version 1.0.0 (build: release, commit: unspeci); installed via Brew
Code of Conduct
I have done the following
Steps to reproduce
.dockerignore:Dockerfile:container build.Problem description
.dockerignoreresolution differs slightly between Docker standard andcontainer build, especially when resolving (un)ignored paths. The provided sample files emit the following error upon building:This causes problems with, e.g., the default Rails .dockerignore configuration as generated by
rails newand it leverages this layering to include/exclude certain subpaths while preserving.keeps.Environment
Code of Conduct