139 cloud runtime_error ai_generated partial

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

Also available as: JSON · Markdown · 中文
78%Fix Rate
82%Confidence
1Evidence
2024-05-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
azure_cli active
app_service_linux active
docker active

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.

generic

中文

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

Official Documentation

https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux

Workarounds

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

中文步骤

  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.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    The crash is due to a segfault, not resource exhaustion; more resources won't fix the code bug.

  2. 95% fail

    Restarting doesn't change the container image; the same segfault will occur again.