<p>I'm deploying a sidecar container in a kubernetes deployment.</p>
<p>The issue is that the pod sometimes is getting restarted many times because the main container (container1) is not ready at all.</p>
<p>The deployment is similar to this one but the sidecar container cannot reach propertly the container1 when this one is not ready. I think that's the reason why the pod is getting restarted many times</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: webserver
spec:
  volumes:
    - name: shared-logs
      emptyDir: {}

  containers:
    - name: container1
      image: image1
      volumeMounts:
        - name: shared-logs
          mountPath: /var/log/nginx

    - name: sidecar-container
      image: busybox
      command: [&quot;sh&quot;,&quot;-c&quot;,&quot;while true; do cat /var/log/nginx/access.log /var/log/nginx/error.log; sleep 30; done&quot;]
      volumeMounts:
        - name: shared-logs
          mountPath: /var/log/nginx
</code></pre>
<p>My question is simple. Is there any way to make busy-box container to wait for container1 until is ready?</p>

X T
<p>In my case, to resolve it faster I have just included a sleep before executing the code so I can give enought time to the main container to be ready.</p>
<pre><code>time.Sleep(8 * time.Second)
</code></pre>
<p>That's not the best solution but resolves the issue.</p>
