<p>I am having trouble distinguishing between a sidecar and an init container. So far, I understand that the real app containers wait for init container to do something. However, sidecar could do the same thing , could it not? And vice versa, init containers don't die off, so also run &quot;on the side&quot;. Hence , my confusion.</p>
<p>Thanks for the help.</p>

<p>Init-containers are used to initialize something inside your Pod. The init-containers will run and exit. After every init container which exits with a code 0, your main containers will start.</p>
<p>Examples for init-containers are:</p>
<ul>
<li>Moving some file into your application containers, e.g. Themes or Configuration. This example is also described in the <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/#create-a-pod-that-has-an-init-container" rel="noreferrer">Kubernetes docs</a>.</li>
</ul>
<p>Kubernetes itself does not know anything about sidecars. Sidecar-Containers are a pattern to solve some use-cases. Usually, Kubernetes distinguishes between Init-Containers and Containers running inside your Pod.</p>
<p>Typically, we call Sidecars all containers, that do not provide a user-focused service. For example, this could be a proxy or something for easier database access. If you're running a Java-App you could use a sidecar to export JVM metrics in Prometheus format.</p>
<p>The difference here is, that your sidecar-containers must run all the time. If one of your not-init-containers exits, kubernetes will restart the whole pod.</p>
<p>And that's the difference.</p>
<ul>
<li>Init containers run and exit before your main application starts</li>
<li>Sidecars run side-by-side with your main container(s) and provide some kind of service for them.</li>
</ul>
