My Azure Web App keeps restarting after successfully loading the images, I am using a docker Compose (Preview) Container

Prabuddha Chatterjee 5 Reputation points
2025-02-26T05:32:11.3733333+00:00

Azure Web App (Docker Compose) Stuck in Restart Loop – Inconsistent Behavior

Issue Description:

I am experiencing an issue where my Azure Web App (Docker Compose - Preview) is stuck in a restart loop. The Web App is deployed using Docker Hub images (both public and private) as a container registry source. The problem is inconsistent—sometimes the application runs fine, but other times it enters a restart loop.

Observations:

The Web App successfully loads images but then restarts randomly.

The issue is not reproducible locally—the same Docker image runs without issues on both Windows and Linux local environments.

No solid error logs can be identified—sometimes restarting the Web App without monitoring logs mysteriously fixes the issue.

Azure "Always On" setting was suspected, as it continuously pings the container. However, enabling/disabling it sometimes helps and sometimes does not.

The Web App is running on the following App Service Plan:

{
    "sku": {
        "name": "B1",
        "tier": "Basic",
        "size": "B1",
        "family": "B",
        "capacity": 1
    },
    "kind": "linux",
    "location": "Central India",
    "type": "Microsoft.Web/serverfarms",
    "maximumNumberOfWorkers": 3,
    "planName": "VirtualDedicatedPlan"
}

Troubleshooting Steps Taken:

  • Checked logs for error messages but found nothing concrete.
  • Ensured the Docker image is built correctly and works locally.
  • Experimented with the Always On setting, but results are inconsistent.
  • Tried redeploying the Web App and restarting it manually—sometimes it works, sometimes it doesn’t.

Possible Causes & Hypothesis:

  1. Container health check failure: If Azure is not receiving a healthy response, it may restart the container.
  2. Startup time issue: If the container takes too long to start, Azure may assume it's unresponsive and restart it.
  3. Azure App Service instability: The Docker Compose (Preview) feature might have bugs.

Seeking Help With:

  1. How can I better diagnose this issue? Any recommended tools or logs to check?
  2. Has anyone else faced a similar problem? How was it resolved?
  3. Are there specific Azure Web App settings that could be causing the restarts?

Any guidance or insights would be greatly appreciated! Thanks in advance for your help.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Shree Hima Bindu Maganti 4,775 Reputation points Microsoft External Staff Moderator
    2025-02-26T20:33:01.1266667+00:00

    Hi @Prabuddha Chatterjee ,
    Welcome to MS Q&A platform.
    If your Azure Web App (Docker Compose - Preview) is stuck in a restart loop, it’s probably because Azure’s container monitoring system is detecting issues and restarting the service automatically. This can happen for a few reasons, like health check failures where Azure pings your container to see if it’s running properly. If the response is off or slow, Azure might think the container is unhealthy and restart it. Another reason could be incorrect port configuration—Azure expects your container to listen on port 80, so if your app runs on something like 3000 or 5000, you need to set the WEBSITES_PORT environment variable in Azure. Also, insufficient resources can cause instability, especially if you’re using a B1 App Service Plan with limited CPU and memory. If your container needs more resources, it might keep crashing and restarting. Upgrading to an S1 or P1V2 plan could help. Lastly, startup script failures might be the culprit if a misconfigured or failing startup command is preventing proper initialization.

    To fix this, start by checking Azure logs (az webapp log tail --name ) to find specific errors causing the restarts. Verify your health check configuration in docker-compose.yml or try disabling health checks temporarily. Make sure your app exposes the correct port and the WEBSITES_PORT setting matches it. If you suspect resource limitations, scale up your App Service Plan for more CPU and memory. Finally, if you use a custom startup script, test it locally to ensure it runs without errors before deploying. These steps should help stabilize your web app and stop the restarts.
    Also, as per Microsoft’s official blog, Azure Web App for Containers keeps pinging the container over HTTP and expects a valid response. If the container doesn't respond in time or is listening on the wrong port, Azure marks it as unhealthy and restarts it. To fix this, make sure your app handles HTTP requests correctly and the right port is exposed using the WEBSITES_PORT setting in Azure App Service.
    You can refer to similar issues discussed in Microsoft Q&A, Stack Overflow, and other Azure documentation.
    Let us know if you need any further assistance!
    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.