I have done the following
Steps to reproduce
Save the script below as repro.sh and run it. It creates two identical build contexts (a Dockerfile + node_modules from npm install) — one under /tmp/ and one under ~/ — and attempts to
build both.
Requires node/npm to be installed.
#!/usr/bin/env bash
set -e
if ! command -v container &>/dev/null; then
echo "Apple Container CLI not found."
exit 1
fi
setup_context() {
local dir="$1"
mkdir -p "$dir"
cat > "$dir/Dockerfile" <<'EOF'
FROM node:20-alpine
WORKDIR /app
COPY . .
CMD ["echo", "hello"]
EOF
cat > "$dir/package.json" <<'PKGJSON'
{
"private": true,
"dependencies": {
"preact": "^10.25.4",
"bootstrap": "^5.3.3",
"d3": "^7.9.0",
"ckeditor5": "^44.3.0",
"typescript": "^5.7.0",
"@types/d3": "^7.4.0"
}
}
PKGJSON
echo "Installing node_modules in $dir..."
(cd "$dir" && npm install --silent 2>&1 | tail -1)
}
echo "=== Test 1: build context under /tmp ==="
DIR1=$(mktemp -d)
setup_context "$DIR1"
echo "Context: $(du -sh "$DIR1" | cut -f1), $(find "$DIR1" -type f | wc -l | tr -d ' ') files"
if container build -t repro-test "$DIR1" 2>&1; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
rm -rf "$DIR1"
echo ""
echo "=== Test 2: same build context under ~/container-bug-repro ==="
DIR2="$HOME/container-bug-repro"
rm -rf "$DIR2"
setup_context "$DIR2"
echo "Context: $(du -sh "$DIR2" | cut -f1), $(find "$DIR2" -type f | wc -l | tr -d ' ') files"
if container build -t repro-test "$DIR2" 2>&1; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
rm -rf "$DIR2"
Expected behavior
Both builds should succeed. The build context content is identical.
Actual behavior
=== Test 1: build context under /tmp ===
Context: 213M, 21989 files
Successfully built repro-test:latest
RESULT: PASS
=== Test 2: same build context under ~/container-bug-repro ===
Context: 214M, 21989 files
Error: unable to write data to the archive, code 0
RESULT: FAIL
Notes
- The error occurs during the CLI's tarball creation phase (before anything is sent to the builder VM), specifically during the [internal] load .dockerignore / transferring context step. - .dockerignore does not help — the error occurs before ignore rules are applied.
- Builder memory (--memory 8G) does not help — the issue is on the CLI side. - --debug flag does not provide additional error detail.
- Small contexts under /Users/ build fine. The threshold appears to be around ~200MB / ~20k files. - Both paths resolve to the same APFS volume (/dev/disk3s1). The difference may be related to macOS TCC / file-access sandbox behavior, since /private/tmp/ is typically exempt from privacy
protections that apply to /Users/.
Problem description
container build fails with Error: unable to write data to the archive, code 0 when the build context directory contains many files (~20k+) and is located under /Users/. The exact same
context directory builds successfully when located under /tmp/ (/private/tmp/).
Environment
- container CLI version 0.11.0 (build: release, commit: d9b8a8d)
- macOS 26.4.1 (25E253)
- Apple Silicon (arm64)
Code of Conduct
I have done the following
Steps to reproduce
Save the script below as repro.sh and run it. It creates two identical build contexts (a Dockerfile + node_modules from npm install) — one under /tmp/ and one under ~/ — and attempts to
build both.
Requires node/npm to be installed.
#!/usr/bin/env bash
set -e
if ! command -v container &>/dev/null; then
echo "Apple Container CLI not found."
exit 1
fi
setup_context() {
local dir="$1"
mkdir -p "$dir"
cat > "$dir/Dockerfile" <<'EOF'
FROM node:20-alpine
WORKDIR /app
COPY . .
CMD ["echo", "hello"]
EOF
cat > "$dir/package.json" <<'PKGJSON'
{
"private": true,
"dependencies": {
"preact": "^10.25.4",
"bootstrap": "^5.3.3",
"d3": "^7.9.0",
"ckeditor5": "^44.3.0",
"typescript": "^5.7.0",
"@types/d3": "^7.4.0"
}
}
PKGJSON
echo "Installing node_modules in $dir..."
(cd "$dir" && npm install --silent 2>&1 | tail -1)
}
echo "=== Test 1: build context under /tmp ==="
DIR1=$(mktemp -d)
setup_context "$DIR1"
echo "Context: $(du -sh "$DIR1" | cut -f1), $(find "$DIR1" -type f | wc -l | tr -d ' ') files"
if container build -t repro-test "$DIR1" 2>&1; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
rm -rf "$DIR1"
echo ""
echo "=== Test 2: same build context under ~/container-bug-repro ==="
DIR2="$HOME/container-bug-repro"
rm -rf "$DIR2"
setup_context "$DIR2"
echo "Context: $(du -sh "$DIR2" | cut -f1), $(find "$DIR2" -type f | wc -l | tr -d ' ') files"
if container build -t repro-test "$DIR2" 2>&1; then
echo "RESULT: PASS"
else
echo "RESULT: FAIL"
fi
rm -rf "$DIR2"
Expected behavior
Both builds should succeed. The build context content is identical.
Actual behavior
=== Test 1: build context under /tmp ===
Context: 213M, 21989 files
Successfully built repro-test:latest
RESULT: PASS
=== Test 2: same build context under ~/container-bug-repro ===
Context: 214M, 21989 files
Error: unable to write data to the archive, code 0
RESULT: FAIL
Notes
protections that apply to /Users/.
Problem description
container build fails with Error: unable to write data to the archive, code 0 when the build context directory contains many files (~20k+) and is located under /Users/. The exact same
context directory builds successfully when located under /tmp/ (/private/tmp/).
Environment
Code of Conduct