[BUG] Edit/Write tools break Docker bind mounts due to atomic rename (inode change)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Description
Claude Code's Edit and Write tools use an atomic rename pattern (write to tempfile, then os.replace(tmp, target)) which creates a new inode for the target file. This breaks Docker bind mounts because Docker's dentry cache holds the old inode reference and never sees the updated content.
This affects anyone running their app in Docker with a bind mount (e.g., .:/var/www/html) — which is an extremely common local development pattern.
Problem: Edit and Write tools use atomic rename (os.replace(tmp, target)) which creates a new inode. Docker bind mounts cache the old inode via the dentry cache and never see the updated file.
Reproduction: Any project using Docker bind mounts (.:/var/www/html) — edit a file with Claude Code, then check inside the container — it still has the old content.
Root cause: In-place writes (open('w') + write) preserve the inode and propagate fine. Atomic rename creates a new inode that the bind mount doesn't pick up.
Workaround: PostToolUse hook that runs docker cp after every Edit/Write.
Root Cause
In-place writes (open('w') + write + close) preserve the original inode → Docker sees the change ✅
Atomic rename (tempfile + os.replace) creates a new inode → Docker's dentry cache still points to the old inode ❌
Claude Code uses the atomic rename pattern for safety (crash-safe writes), but this has the side effect of breaking bind mount file visibility.
What Should Happen?
Expected Behavior
File changes made by Claude Code should be visible inside Docker containers using bind mounts, just like changes made by any normal editor, vim, nano, echo >, etc.
Workaround
PostToolUse hook that runs docker cp after every Edit/Write:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "/path/to/docker-sync.sh"
}
]
}
]
}
}
Where docker-sync.sh reads the tool input JSON from stdin and runs docker cp to sync the file.
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
Have a project with a Docker bind mount (e.g., docker-compose.yml with volumes: [".:/var/www/html"])
Use Claude Code to edit any file via the Edit or Write tool
Check the file inside the container: docker exec <container> cat /path/to/file
The container still has the old content
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.12 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
Suggested Fix
Consider offering an option for in-place writes that preserve the file inode (open + truncate + write), or at minimum document this known limitation for Docker bind mount users.
Environment
Claude Code (VS Code extension)
Docker with bind mounts on Linux
Affects any containerized local dev environment
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗