#10174: fix(docker): exclude .env files from Docker build context
docker
stale
## Fix Summary
- Add `.env` and `.env.*` to `.dockerignore` to prevent secrets written by `docker-setup.sh` (`OPENCLAW_GATEWAY_TOKEN`, etc.) from being embedded into image layers via `COPY . .` in the Dockerfile
## Issue Linkage
Fixes #10173
## Security Snapshot
| Metric | Value |
|--------|-------|
| **Score** | 9.1 / 10.0 |
| **Severity** | Critical |
| **Vector** | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N |
## Implementation Details
### Files Changed
- `.dockerignore` (+2/-0)
### Technical Analysis
- Add `.env` and `.env.*` to `.dockerignore` to prevent secrets written by `docker-setup.sh` (`OPENCLAW_GATEWAY_TOKEN`, etc.) from being embedded into image layers via `COPY . .` in the Dockerfile
## Validation Evidence
- Command: `pnpm build`
- Status: passed
## Risk and Compatibility
non-breaking; compatibility impact was not explicitly documented in the original PR body.
## AI-Assisted Disclosure
- AI-assisted: yes
- Model: Claude Code
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the Docker build context ignore rules by adding `.env` and `.env.*` to `.dockerignore`, preventing secrets created locally (e.g., by `docker-setup.sh`) from being included in the build context and embedded into image layers via `COPY . .`.
Change is isolated to `.dockerignore` and aligns with the existing pattern of excluding local-only artifacts and sensitive files from Docker builds.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is a small, targeted update to `.dockerignore` that reduces the chance of secret leakage into Docker image layers; no functional code paths are modified.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#13953: feat(docker): add .env template and improve Dockerfile
by n24q02m · 2026-02-11
81.6%
#7342: fix(docker): ensure readability of docker-setup.sh
by esc-ouni · 2026-02-02
80.2%
#2609: bugfix: Docker build fails on main: .dockerignore excludes required...
by yanquankun · 2026-01-27
79.8%
#14308: fix(sandbox): pass docker.env config to container creation
by wboudy · 2026-02-11
78.8%
#19538: security: migrate sensitive Docker env vars to Docker secrets
by Mozzzaic · 2026-02-17
78.5%
#7133: feat: Automated Docker setup with environment-based configuration
by synetalsolutions · 2026-02-02
78.1%
#8161: fix(sandbox): block dangerous environment variables from Docker con...
by yubrew · 2026-02-03
77.0%
#3240: Fix Docker build failures on Windows/WSL environments
by Attili-sys · 2026-01-28
76.8%
#17506: Fix Entrypoint in docker-compose
by NeilSCGH · 2026-02-15
76.5%
#22344: feat(docker): add pre-built image mode for docker-setup
by AIflow-Labs · 2026-02-21
76.4%