- Co-located containers (multiple concurrent containers in a Pod)
initContainers(sequential startup tasks)- Sidecar containers (long-running helpers that share a Pod)
Co-located containers
Co-located containers are multiple containers defined together in the Pod’scontainers array. They run concurrently for the lifetime of the Pod. Kubernetes does not guarantee a strict startup ordering between containers listed under containers; they are created and started, but ordering is non-deterministic. If a container terminates, Pod-level restartPolicy determines whether the container (and therefore the Pod) is restarted.
When to use:
- Two or more processes must run together in the same Pod and ordering is not important.
- Processes communicate via
localhostor share volumes for fast IPC.
initContainers
initContainers are defined in the Pod spec under a separate initContainers field. Init containers run sequentially and each must exit successfully before Kubernetes starts any of the regular containers in containers. They are restarted on failure according to the Pod’s restartPolicy. Use init containers for deterministic initialization work such as database readiness checks, schema migrations, or provisioning files.
When to use:
- You need a guaranteed startup order for setup tasks.
- Tasks must complete before the main application begins.
Sidecar containers
A sidecar is an auxiliary container that runs alongside one or more main application containers in the same Pod. Sidecars are regular entries under thecontainers array, so they run concurrently with the app and typically remain active for the Pod’s lifetime. Typical sidecar use cases are logging, metrics/telemetry, proxying, and caching.
Important characteristics:
- Sidecars run concurrently with application containers (no guaranteed ordering).
- Use coordination techniques (readiness probes, shared volumes, or explicit init containers) if you need deterministic sequencing between sidecare and app.
- Sidecars share the same network namespace and can access the app via
localhost.
restartPolicy is a Pod-level field (default Always for Pods created by controllers):
Init containers provide deterministic startup order: they run in the order listed and must finish successfully before
containers start. Containers under containers (including sidecars) run concurrently and do not have guaranteed startup ordering.
Real-world logging example
A common production use of sidecars is a log collector such as Filebeat running as a sidecar. The sidecar can:- Start alongside your app to capture initialization logs,
- Forward logs to a backend such as Elasticsearch,
- Continue running to capture termination logs if the application crashes.

Comparison at a glance
Examples and best practices
- If ordering matters for startup, prefer
initContainersor implement coordination (readiness probes, shared files, in-Pod health checks). - Keep sidecars lightweight and focused (single responsibility).
- Use shared volumes for log or config exchange between containers.
- Prefer higher-level controllers (Deployments, StatefulSets) to manage Pod lifecycle in production.
- Kubernetes Pods
- Init Containers
- Sidecar Pattern — Istio / Service Mesh docs and general patterns
- Filebeat
- Elasticsearch
- Kibana
Summary
- Use co-located containers when processes must run together but ordering is unimportant.
- Use
initContainersfor deterministic, sequential setup tasks that must finish before the main app starts. - Use sidecars for long-lived helpers (logging, proxies, telemetry). Because sidecars run concurrently, coordinate startup and shutdown explicitly when ordering matters.