Azure Container Instance killed for no reason after a few hours

jbx999 256 Reputation points
2021-02-21T11:52:12.423+00:00

I have a very simple Azure Container Instance running from a Docker container based on AdoptOpenJDK. The Dockerfile has nothing but:

   FROM adoptopenjdk:11-jre-hotspot  
   ARG JAR_FILE=target/*.jar  
   COPY ${JAR_FILE} app.jar  
   ENTRYPOINT ["java","-jar","/app.jar"]  

The application itself is a very simple Spring Boot Application exposing a REST API. It currently does nothing but expose a simple request for testing. The application is not doing any logic so there is nothing related to load or resource consumption. In fact the graph shows a practically constant usage at around 285Mb. According to the Properties of the container it has 1.5Gb of memory, so it shouldnt be a resource issue.

70363-image.png

However, after a few hours of running happily, the container is just killed. I am also noticing it on a more complex application, but I wanted to verify it with a simpler one.
I am deploying the container with this command:

   az container create --dns-name-label $ACI_CONTAINER_NAME --resource-group $AZURE_RESOURCE_GROUP --name $ACI_CONTAINER_NAME --image $IMAGE_NAME:latest --registry-username $ACR_USERNAME --registry-password $ACR_PASSWORD --restart-policy Never --ports 80 --environment-variables $MY_VARIABLES --secure-environment-variables $MY_SECURE_VARIABLES  

I have set the restart policy on purpose to Never so that I can see the logs of the container, but there is nothing that shows any problem.

Sometimes the container is killed after a few hours, sometimes after a bit longer. In this case it was killed after 20hrs.

70359-image.png

I can see nothing else in the container logs.

How can I know what is going on? Why is ACI just killing my instances arbitrarily?

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
461 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
710 questions
{count} votes

Accepted answer
  1. jbx999 256 Reputation points
    2021-04-04T10:53:01.513+00:00

    In the end I decided to move away from Azure Container Instances. They are a buggy, unstable, half baked product. After more than 6 weeks of investigation by Support, West EU containers are still being killed without any reason, while containers running in East US have been running happily since February. Furthermore, I just discovered that the cost to expose an ACI which is inside a vnet, due to the fact that you need to have an Application Gateway, costs more than the container instance itself! They are marketed as a low cost solution instead of a VM, while in fact they will cost double that, without the stability.

    My personal advice, stay away from Azure Container Instances.

    4 people found this answer helpful.

6 additional answers

Sort by: Most helpful
  1. Motzek Andreas 1 Reputation point
    2021-07-16T12:47:13.573+00:00

    Same problem here. It seems that container restarts are more frequent, if there are more containers in an ACI. But as jbx999 stated, it happens also with a very small Spring Boot app running in an ACI for itself.

    0 comments No comments

  2. Marian Dobesch FIS-ASP 0 Reputation points
    2024-01-17T13:22:35.4966667+00:00

    I had the same issue today, in my case, the container is supposed to run a RHEL image. I was able to fix it with this article: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting?WT.mc_id=Portal-Microsoft_Azure_Support#container-continually-exits-and-restarts-no-long-running-process Steps to fixing:

    1. Deleted the problematic container group.
    2. Created a new container group through Azure CLI, adding --restart-policy OnFailure --command-line "tail -f /dev/null" to the create command, as suggested in the article. Container is running fine, it seems. The main issue seemed to be what is written in the attached screenshot, at the end of the linked paragraph: "Most container images for Linux distributions set a shell, such as bash, as the default command. Since a shell on its own is not a long-running service, these containers immediately exit and fall into a restart loop when configured with the default Always restart policy." This might be the issue for other "services" as well. User's image
    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.