# ERROR: Service 'app' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

- **ID:** `docker/container-exit-code-1-during-build`
- **Domain:** docker
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

A RUN command in Dockerfile fails, usually due to missing dependencies, network issues, or incorrect package versions.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 24.0.7 | active | — | — |
| Docker 25.0.3 | active | — | — |
| Docker 23.0.6 | active | — | — |

## Workarounds

1. **Check the specific error message in the build output (e.g., 'Could not find a version that satisfies the requirement'). Then update requirements.txt or base image. Example: use 'pip install --upgrade pip' before installing requirements.** (85% success)
   ```
   Check the specific error message in the build output (e.g., 'Could not find a version that satisfies the requirement'). Then update requirements.txt or base image. Example: use 'pip install --upgrade pip' before installing requirements.
   ```
2. **If network issues, add a retry mechanism in the RUN command: RUN pip install -r requirements.txt || (sleep 5 && pip install -r requirements.txt)** (75% success)
   ```
   If network issues, add a retry mechanism in the RUN command: RUN pip install -r requirements.txt || (sleep 5 && pip install -r requirements.txt)
   ```

## Dead Ends

- **** — Adding --no-cache-dir to pip install does not fix underlying package conflicts or network errors. (80% fail)
- **** — Running the command manually inside a running container without the correct base image may succeed but fail during build due to different environment. (90% fail)
