ACI init container does not follow its group's restartPolicy

Anonymous
2025-09-30T09:36:40.7866667+00:00

Issue: Init container ignores restartPolicy: Never and restarts indefinitely

Setup:

  • Container group with restartPolicy: Never
  • Init container intentionally fails with exit 1

Expected: Init container should fail once and container group should stop/terminate

Actual:

  • Init container continuously restarts
  • State: CrashLoopBackOff: Back-off restarting failed
  • Container group stays in provisioningState: Creating indefinitely
  • Container group takes a long time to reach terminal Failed state
Azure Container Instances
{count} votes

1 answer

Sort by: Most helpful
  1. Nikhil Duserla 9,280 Reputation points Microsoft External Staff Moderator
    2025-10-01T16:04:43.82+00:00

    Hello Vu Phan,

    Scope of restartPolicy: Never The restartPolicy: Never setting applies to the entire Pod or container group, not to individual containers. However, this policy does not prevent init containers from restarting upon failure.

    Behavior of Init Containers Init containers is designed to run to completion before the main containers start.

    • If an init container fails, the orchestrator will repeatedly retry it until it either succeeds, or the Pod/container group is deleted.
    • This retry behavior occurs even if restartPolicy: Never is set.

    Documentation and Observed Behavior While the Azure Container Instances (ACI) documentation indicates that restartPolicy: Never should prevent restarts, this does not reliably apply to init containers.

    Container State in ACI ACI exposes multiple independent state values for containers.

    • These can be viewed in the JSON definition of the container resource.
    • In the Azure portal, this information is available under Essentials in the Overview blade.

    Best Practice: Avoid Relying on restartPolicy: Never Because restartPolicy: Never does not guarantee init containers won't restart, it's best to avoid relying on this behavior for controlling container lifecycle.

    Recommended Alternatives Consider more reliable design patterns, such as:

    • Merging initialization logic into the main container, so everything runs as a single, controlled process.
    • Using a startup script within a single container that handles initialization steps before continuing or exiting gracefully.

    If you have any further queries, do let us know.

    0 comments No comments

Your answer

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