# CrashLoopBackOff：应用服务 'myapp-linux' 中的容器 'myapp' 反复崩溃。错误：'容器以代码 139 退出（段错误）'

- **ID:** `cloud/azure-app-service-linux-container-crash-loop`
- **领域:** cloud
- **类别:** runtime_error
- **错误码:** `139`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

容器镜像出现段错误，通常是由于基础镜像不兼容（例如，使用 Alpine 但应用程序依赖 glibc）或应用程序内存损坏。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| azure_cli | active | — | — |
| app_service_linux | active | — | — |
| docker | active | — | — |

## 解决方案

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.
   ```
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.
   ```

## 无效尝试

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