# CrashLoopBackOff: Container 'myapp' in App Service 'myapp-linux' is repeatedly crashing. Error: 'Container exited with code 139 (Segmentation fault)'

- **ID:** `cloud/azure-app-service-linux-container-crash-loop`
- **Domain:** cloud
- **Category:** runtime_error
- **Error Code:** `139`
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

The container image has a segmentation fault, often due to incompatible base image (e.g., Alpine with glibc-dependent binaries) or memory corruption in the application.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| azure_cli | active | — | — |
| app_service_linux | active | — | — |
| docker | active | — | — |

## Workarounds

1. **Switch the Docker base image from Alpine to a glibc-based image like Debian or Ubuntu. For example, change `FROM python:3.11-alpine` to `FROM python:3.11-slim-bookworm` in your Dockerfile, rebuild, and redeploy.** (85% success)
   ```
   Switch the Docker base image from Alpine to a glibc-based image like Debian or Ubuntu. For example, change `FROM python:3.11-alpine` to `FROM python:3.11-slim-bookworm` in your Dockerfile, rebuild, and redeploy.
   ```
2. **Enable diagnostic logs: `az webapp log config --name myapp-linux --resource-group myrg --docker-container-logging filesystem` then check logs at `/home/LogFiles/docker/` for more details on the segfault. Fix the application code (e.g., null pointer dereference) and rebuild the image.** (90% success)
   ```
   Enable diagnostic logs: `az webapp log config --name myapp-linux --resource-group myrg --docker-container-logging filesystem` then check logs at `/home/LogFiles/docker/` for more details on the segfault. Fix the application code (e.g., null pointer dereference) and rebuild the image.
   ```

## Dead Ends

- **** — The crash is due to a segfault, not resource exhaustion; more resources won't fix the code bug. (90% fail)
- **** — Restarting doesn't change the container image; the same segfault will occur again. (95% fail)
