<p>I have two containers in my POD. First container is my main application and second is used as sidecar container having following images having following Dockerfile.</p>

<pre><code>FROM scratch

EXPOSE 8080
ADD my-binary /

ENV GOROOT=/usr/lib/go
ENTRYPOINT ["/my-binary"]
</code></pre>

<p>Basically it's using <strong>scratch</strong> and my-binary is a go application which running as process. So I cannot <strong>exec</strong> on this side car container. I have a requirement to re-start the side container(my-binary), but there should be no change in the main container. Main container should not be altered in any way.</p>

<p>Is there any possibility, how I can achieve this?</p>

<p>Thank you so much for looking into this.</p>

<p>Someone has asked to provide the complete details of POD, then you can consider following pod structure</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  labels:
    app: my-deploy
spec:
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: main
        image: my-main-app-image
        ports:
        - containerPort: 80
      - name: my-go-binary
        image: my-go-binary-image
</code></pre>

<p>Please note- </p>

<pre><code>kubectl exec POD_NAME -c CONTAINER_NAME reboot 
</code></pre>

<p>this is not going to work for 2nd container as it is scratch image.</p>

nagendra547
<p>So, your <code>reboot</code> command wasn't working (of course it will newer work) cause of using <code>scatch</code> as the base image.</p>

<blockquote>
  <p>This image is most useful in the context of building base images (such as <a href="https://registry.hub.docker.com/_/debian/" rel="nofollow noreferrer">debian</a> and <a href="https://registry.hub.docker.com/_/busybox/" rel="nofollow noreferrer">busybox</a>) or super minimal images (that contain only a single binary and whatever it requires, such as hello-world).</p>
</blockquote>

<p>See, <a href="https://hub.docker.com/_/scratch" rel="nofollow noreferrer">https://hub.docker.com/_/scratch</a></p>

<blockquote>
  <p>The base image <code>scratch</code> is Docker's reserved minimal image. It can be a starting point for building small-sized containers. Using the <code>scratch</code> “image” signals to the build process that you want the next command in the Dockerfile to be the first filesystem layer in your image.</p>
</blockquote>

<p>Ref: <a href="https://docs.docker.com/develop/develop-images/baseimages/#create-a-simple-parent-image-using-scratch" rel="nofollow noreferrer">https://docs.docker.com/develop/develop-images/baseimages/#create-a-simple-parent-image-using-scratch</a></p>

<p>From you provided dockerfile, there is the only filesystem is your go-binery. There is nothing other than this. That's why you can't (couldn't) run <code>reboot</code> command. If you change the base image like <code>busybox</code> or <code>alpine</code> or anything other you will be able to run the <code>reboot</code> command.</p>

<blockquote>
  <p>But keep in mind that your new base image must have a proper shell to run your expected command. For example, the <code>busybox</code> image has shell (<code>bash</code>) and so it's possible to run <code>reboot</code> command. And the <code>alpine</code> image has shell (<code>sh</code>) too.</p>
</blockquote>
