Search code examples
dockeropenshiftopenshift-enterprise

What is the benefit of putting multiple containers in a pod?


What's the benefit of having multiple containers in a pod versus having standalone containers?


Solution

  • If you have multiple containers in the same pod, they can speak to each other as localhost and can share mounted volumes.

    If you have multiple pods of one container each, you can restart one without restarting the other. Assuming they're controlled by deployments, you can add additional replicas of one without necessarily scaling the other. If the version or some other characteristic of one of them changes, you're not forced to restart the other. You'd need to set up a service to talk from one to the other, and they can't communicate via a filesystem.

    The general approach I've always seen is to always have one container per pod within a deployment, unless you have a specific reason to need an additional container. Usually this is some kind of special-purpose "sidecar" that talks to a credentials service, or manages logging, or runs a network proxy, or something else that's secondary to the main thing the pod does (and isn't a separate service in its own right).