Init Containers
Init Containers are specialized containers that run before application containers start in a Pod.
A Pod can have multiple init containers.
Differences from Regular Application Containers
- Regular application containers can remain in a running state (Running); init containers must reach a terminated state (Terminated).
- A Pod can have multiple application containers running simultaneously, but init containers must execute sequentially — each one must complete successfully before the next one starts.
- Init containers do not support readiness probes, because init containers must finish running before the Pod is considered ready.
How to Use
Init containers are configured via the initContainers field in the PodSpec.
Below is an example of init containers in use.
1 | apiVersion: v1 |
When Do Init Containers Run
- When a new Pod is created.
- After a Pod restarts, all init containers need to run again.
- When a configuration change in the Pod causes an init container to change. Changing an init container’s image will restart the entire Pod, while changing an application container’s image only restarts the application container.
- When the Pod infrastructure container restarts.