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: Neveris 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.