Sobes.tech
Junior

Can multiple containers be in a single pod?

sobes.tech AI

Answer from AI

Yes, it can. This is common practice in Kubernetes.

Multiple containers in a pod usually share resources (storage volume, network stack) and are often used for auxiliary tasks alongside the main application container (Sidecar pattern).

Examples of usage:

  • Sidecar containers: Monitoring, logging, service mesh proxy (e.g., Envoy).
  • Ambassador containers: Proxy for external service access.
  • Adapter containers: Normalization of auxiliary process output.

Containers in a pod are always scheduled on the same node and share the same IPC namespace, allowing them to interact.

Example of a pod manifest with two containers (main nginx app and a sidecar for logging):

apiVersion: v1
kind: Pod
metadata:
  name: multi-container-pod
spec:
  containers:
    - name: main-app
      image: nginx:latest
      ports:
        - containerPort: 80
    - name: log-sidecar
      image: busybox:latest
      args:
        - /bin/sh
        - -c
        - while true; do echo "Logging from sidecar..."; sleep 5; done