apple / apple/container

[Bug]: `container build` ignores default/relative build context in `mktemp` directory, but works with absolute path

Open
#1,899 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
49.9k
Forks
1.8k
Avg merge
1d 20h
Merged PRs (30d)
22

Description

### I have done the following

- [x] I have searched the existing issues
- [ ] If possible, I've reproduced the issue using the 'main' branch of this project

### Steps to reproduce

```sh
cd "$(mktemp -d)"

cat > Dockerfile <<'EOF'
FROM debian:stable-slim
COPY . .
RUN cat Dockerfile
EOF

container build
```

The build fails with:

```text
cat: Dockerfile: No such file or directory
```

The same happens with:

```sh
container build .
```

But this succeeds:

```sh
container build "$PWD"
```

In my specific example reproduction, the `mktemp -d` resolved to `/var/folders/qf/ng024_6s5kn4z_sczdcdbbkh0000gn/T/tmp.3tuwoUOXS3`.

### Problem description

When building from a temporary directory created with `mktemp -d`, the build context appears to be empty if the context is specified implicitly or as `.`.

The following commands all produce an empty build context:

`container build`
`container build .`

However, providing the exact same directory as an absolute path works:

`container build "$PWD"`

The behavior does not occur when building from a normal directory such as `~/test`.

### Environment

```markdown
- OS: ProductName: macOS
ProductVersion: 26.5.2
BuildVersion: 25F84
- Container: container CLI version 1.0.0 (build: release, commit: ee848e3)
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in the `container build` entry point from a macOS temporary directory, comparing omitted, relative (`.`), and absolute contexts. Trace how the build context is resolved and transferred, then verify that `container build` and `container build .` include Dockerfile and other files just as the absolute-path invocation does.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.