Running a tutorial Container Instance. Keeps restarting.

Marcel-Jan Krijgsman 25 Reputation points
2025-02-10T22:16:06.4966667+00:00

I've got a bit of experience with Docker images. But I'm quite new to Azure Container Instances. So I've tried to push an image of my own. That was successful. But it kept restarting. So to better understand the situation, I thought it be better to start with the tutorial image.

I've followed these tutorials:

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-deploy-app

I'm using a managed identity according to this document:

https://learn.microsoft.com/en-us/azure/container-instances/using-azure-container-registry-mi

The image is available.

az acr repository show --name mycontainerregister --repository "aci-tutorial-app"

{

"changeableAttributes": {

"deleteEnabled": true,

"listEnabled": true,

"readEnabled": true,

"writeEnabled": true

},

"createdTime": "2025-02-10T09:47:17.9047564Z",

"imageName": "aci-tutorial-app",

"lastUpdateTime": "2025-02-10T09:47:17.9640607Z",

"manifestCount": 1,

"registry": "mycontainerregister.azurecr.io",

"tagCount": 1

}

After trying a lot of different options I got it successfully running:

az container create --name aci-tutorial-app --resource-group MyRG --image mycontainerregister.azurecr.io/aci-tutorial-app --cpu 1 --memory 1 --acr-identity $USERID --assign-identity $USERID --ports 80 --os-type Linux --ip-address Public --dns-name-label aci-tutorial-appmjk2025

{

"confidentialComputeProperties": null,

"containerGroupProfile": null,

"containers": [

{

"command": null,

"configMap": {

"keyValuePairs": {}

},

"environmentVariables": [],

"image": "mycontainerregister.azurecr.io/aci-tutorial-app",

"instanceView": {

"currentState": {

"detailStatus": "CrashLoopBackOff: Back-off restarting failed",

"exitCode": null,

"finishTime": null,

"startTime": null,

"state": "Waiting"

},

"events": [

{

"count": 1,

"firstTimestamp": "2025-02-10T21:50:03+00:00",

"lastTimestamp": "2025-02-10T21:50:03+00:00",

"message": "pulling image \"mycontainerregister.azurecr.io/aci-tutorial-app:latest\"",

"name": "Pulling",

"type": "Normal"

},

{

"count": 1,

"firstTimestamp": "2025-02-10T21:50:14+00:00",

"lastTimestamp": "2025-02-10T21:50:14+00:00",

"message": "Successfully pulled image \"mycontainerregister.azurecr.io/aci-tutorial-app:latest\"",

"name": "Pulled",

"type": "Normal"

},

{

"count": 2,

"firstTimestamp": "2025-02-10T21:50:25+00:00",

"lastTimestamp": "2025-02-10T21:50:41+00:00",

"message": "Started container",

"name": "Started",

"type": "Normal"

},

{

"count": 1,

"firstTimestamp": "2025-02-10T21:50:29+00:00",

"lastTimestamp": "2025-02-10T21:50:29+00:00",

"message": "Container aci-tutorial-app terminated with ExitCode 1.",

"name": "Killing",

"type": "Normal"

}

],

"previousState": {

"detailStatus": "Error",

"exitCode": 1,

"finishTime": "2025-02-10T21:50:47.808000+00:00",

"startTime": "2025-02-10T21:50:41.629000+00:00",

"state": "Terminated"

},

"restartCount": 1

},

"livenessProbe": null,

"name": "aci-tutorial-app",

"ports": [

{

"port": 80,

"protocol": "TCP"

}

],

"readinessProbe": null,

"resources": {

"limits": null,

"requests": {

"cpu": 1.0,

"gpu": null,

"memoryInGb": 1.0

}

},

"securityContext": null,

"volumeMounts": null

}

],

"diagnostics": null,

"dnsConfig": null,

"encryptionProperties": null,

"extensions": null,

"id": "/subscriptions/123d456g-9876-12d0-2109-a12345bc6789/resourceGroups/MyRG/providers/Microsoft.ContainerInstance/containerGroups/aci-tutorial-app",

"identity": {

"principalId": null,

"tenantId": "c2d1596d-9adc-4307-9ecc-36c6808a6859",

"type": "UserAssigned",

"userAssignedIdentities": {

"/subscriptions/123d456g-9876-12d0-2109-a12345bc6789/resourcegroups/MyRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cvgen_ident": {

"clientId": "0c6146e4-4fcf-494f-8905-34f5ab7e47e6",

"principalId": "7cb5b409-2b9c-4d70-8c5d-c6296ec146fe"

}

}

},

"imageRegistryCredentials": [

{

"identity": "/subscriptions/123d456g-9876-12d0-2109-a12345bc6789/resourcegroups/MyRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/cvgen_ident",

"identityUrl": null,

"isDelegatedIdentity": false,

"password": null,

"server": "mycontainerregister.azurecr.io",

"username": null

}

],

"initContainers": [],

"instanceView": {

"events": [],

"state": "Running"

},

"ipAddress": {

"autoGeneratedDomainNameLabelScope": "Unsecure",

"dnsNameLabel": "aci-tutorial-appmjk2025",

"fqdn": "aci-tutorial-appmjk2025.westeurope.azurecontainer.io",

"ip": "108.141.10.157",

"ports": [

{

"port": 80,

"protocol": "TCP"

}

],

"type": "Public"

},

"isCreatedFromStandbyPool": false,

"location": "westeurope",

"name": "aci-tutorial-app",

"osType": "Linux",

"priority": null,

"provisioningState": "Succeeded",

"resourceGroup": "MyRG",

"restartPolicy": null,

"sku": "Standard",

"standbyPoolProfile": null,

"subnetIds": null,

"tags": {},

"type": "Microsoft.ContainerInstance/containerGroups",

"volumes": null,

"zones": null

}

The Azure Portal says it's Running, but also that it has been Killed and Restarted numerous times. The logs page says "No Logs Available".

What could I be missing? I've already spent so many hours to get this working. I sort of expected this to be a tiny bit easier.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
727 questions
{count} votes

Accepted answer
  1. anashetty 2,120 Reputation points Microsoft Vendor
    2025-02-11T09:19:31.22+00:00

    Hi Marcel-Jan Krijgsman,

    Good catch! Glad the issue is resolved for you finally. I will have this answer promoted by reposting it. As an Original Poster (You) will not be able to accept your own answer. This is in the attempt to help others looking for a solution for a similar issue.

    Issue:

    Running a tutorial Container Instance. Keeps restarting.

    Solution:

    I've got it working. Not with the extra CPU though. I created the container instance once more but with the restart policy Never. And then I got one message in the log on the Portal:

    standard_init_linux.go:228: exec user process caused: exec format error

    When I looked that up, I found a Stack Overflow answer telling that the error occurs in Docker when you build a Docker image based on a different platform (in my case MacOS with M1 processor). That explains why the image run fine when I tested it locally.

    I build the image again with option --platform linux/amd64:

    docker build . --platform linux/amd64 -t aci-tutorial-app

    I pushed the image to the container registry. I checked that it was updated. And when I created the container instance again (from the Portal this time), it kept running.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    User's image

    Thanks again for sharing the solution here. Have a good day!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Marcel-Jan Krijgsman 25 Reputation points
    2025-02-11T08:56:20.57+00:00

    I've got it working. Not with the extra CPU though. I created the container instance once more but with the restart policy Never. And then I got one message in the log on the Portal:

    standard_init_linux.go:228: exec user process caused: exec format error

    When I looked that up, I found a Stack Overflow answer telling that the error occurs in Docker when you build a Docker image based on a different platform (in my case MacOS with M1 processor). That explains why the image run fine when I tested it locally.

    I build the image again with option --platform linux/amd64:

    docker build . --platform linux/amd64 -t aci-tutorial-app

    I pushed the image to the container registry. I checked that it was updated. And when I created the container instance again (from the Portal this time), it kept running.

    Thanks for the response though. I'll try building in the liveness probe.

    1 person found this answer helpful.
    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.