Skip to content

Commit f11ca91

Browse files
authored
docs: update bug note docs (#54)
- update bug note docs
1 parent ec003f1 commit f11ca91

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

.dev/02-docker-git-testing-bug.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,49 @@
99

1010
## Root Cause
1111

12-
**Docker Image Entrypoint Issue**: `alpine/git:latest` has `git` as the default entrypoint, not `sh`. This means:
12+
**Docker Image Entrypoint Issue**: `alpine/git:latest` has `git` as the default entrypoint, not `sh`.
1313

14-
- Local Docker might behave differently than CI
15-
- Commands like `docker run alpine/git:latest "git init"` try to execute `git "git init"` instead of `sh -c "git init"`
14+
### Why Local vs CI Behaves Differently
15+
16+
**Docker Runtime Environment Differences:**
17+
18+
- **Local (Docker Desktop)**: More permissive, has compatibility layers that can "fix" some incorrect commands
19+
- **CI (Docker Engine)**: Stricter, follows Docker specifications exactly
20+
21+
**Entrypoint Handling Differences:**
22+
23+
```bash
24+
# What we were doing (WRONG):
25+
docker run alpine/git:latest "git init"
26+
27+
# Local Docker Desktop might interpret this as:
28+
# -> Run git with argument "git init"
29+
# -> Sometimes works due to shell interpretation
30+
31+
# CI Docker Engine interprets this as:
32+
# -> Run git "git init" (literally passes "git init" as argument to git)
33+
# -> Always fails: git doesn't understand "git init" as a single argument
34+
```
35+
36+
**Environment Masking:**
37+
38+
- **Local**: Your shell might have different PATH, git configs, or environment variables that mask issues
39+
- **CI**: Clean, minimal environment exposes the exact Docker behavior
40+
41+
**The Core Issue:**
42+
`alpine/git:latest` has `ENTRYPOINT ["git"]`, so:
43+
44+
```bash
45+
# Without --entrypoint sh:
46+
docker run alpine/git:latest "some command"
47+
# Actually executes: git "some command"
48+
# ❌ This tries to run git with "some command" as a single argument
49+
50+
# With --entrypoint sh:
51+
docker run --entrypoint sh alpine/git:latest -c "some command"
52+
# Actually executes: sh -c "some command"
53+
# ✅ This runs the command in shell properly
54+
```
1655

1756
## Complete Fix Pattern
1857

@@ -160,4 +199,11 @@ cargo test git --include-ignored
160199
git push # Check GitHub Actions
161200
```
162201

202+
## Why This Bug Repeats
203+
204+
1. **Local testing masks the issue** - Docker Desktop is more forgiving
205+
2. **The error is subtle** - Commands might partially work locally
206+
3. **CI environment is different** - Only fails in the strict CI environment
207+
4. **Git directory context** - After `git init`, subsequent commands need `--git-dir=.git` in containers
208+
163209
This bug has occurred multiple times - always refer to this guide when Docker git tests fail in CI but pass locally.

0 commit comments

Comments
 (0)