Forum Discussion

LouisT's avatar
LouisT
Copper Contributor
Dec 04, 2025

Container on App Service keeps getting stopped and terminated

I've got a .Net app running in a Docker container that I'm trying to run on a Linux App Service but as per the (sanitised) log output below from the Platform log stream, it's getting terminated only 4 seconds after it started.

Where can I get information on why this is happening?

Starting container: a0e3af0a_myapp-dev-as.
Starting watchers and probes.
Starting metrics collection.
Container is running.
Container start method finished after 1990 ms.
Container is terminating. Grace period: 0 seconds.
Stop and delete container. Retry count = 0

Timestamps removed as the forum doesn't seem to like log output?

1 Reply

  • When a custom container on Linux App Service terminates only a few seconds after start and the log shows:

    Container is running.

    Container start method finished…

    Container is terminating. Grace period: 0 seconds.

    it usually means the entrypoint process exited, even if the platform briefly reports “running.”

    Key causes to check:

    1. Your container’s main process is stopping immediately
      App Service requires the entrypoint to stay alive. If your .NET app runs, prints logs, and then exits (for example, missing a web server binding), the container is deleted instantly.
    2. The app is not listening on the required port
      Linux App Service expects the app to listen on port 8080 (or the port defined in WEBSITES_PORT).
      If the container listens on 5000/80/etc. without exposing 8080, the health probe fails and App Service stops the container.
    3. No “long-running” foreground process
      If the app launches and then returns control to the shell (for example, backgrounding the process), App Service treats it like a completed job and terminates it.
    4. Dockerfile CMD/ENTRYPOINT mismatch
      A misconfigured Dockerfile can cause the runtime to exit instantly:
    • ENTRYPOINT overwritten by App Service
    • Using CMD ["dotnet", "myapp.dll"] but the DLL is missing or misnamed
    • Health probes not compatible with the container path

    Recommended steps:

    • Check container logs in Log Stream → Container Logs.
    • Ensure your app listens on the same port as WEBSITES_PORT.
    • Add a simple while true; do sleep 30; done to test whether the container stays alive.
    • Run the image locally (docker run -p 8080:8080 image) to confirm it behaves as expected.

    In almost all cases, the termination time (~4 seconds) indicates the container is exiting by itself, not being forcefully stopped by App Service.

Resources