<p>I want to execute <code>set</code> in a pod, to analyze the environment variables:</p>
<pre><code>kubectl exec my-pod -- set
</code></pre>
<p>But I get this error:</p>
<pre><code>OCI runtime exec failed: exec failed: container_linux.go:370: starting container process caused: exec: &quot;set&quot;: executable file not found in $PATH: unknown
</code></pre>
<p>I think, this is a special case, because there's no executable <code>set</code> like there's for example an execute <code>ls</code>.</p>
<p><strong>Remarks</strong></p>
<ul>
<li>When I open a shell in the pod, it's possible to call <code>set</code> there.</li>
<li>When I call <code>kubectl exec</code> with other commands, for example <code>ls</code>, I get no error.</li>
<li>There are some other questions regarding <code>kubectl exec</code>. But these do not apply to my question, because my problem is about executing <code>set</code>.</li>
</ul>

Matthias M
<p><code>set</code> is not a binary but instead a shell command that sets the environment variable.</p>
<p>If you want to set an environment variable before executing a follow up command consider using <code>env</code></p>
<pre class="lang-sh prettyprint-override"><code>kubectl exec mypod -- env NAME=value123 script01

# or 

kubectl exec mypod -- /bin/sh -c 'NAME=value123 script01'
</code></pre>
<p>see <a href="https://stackoverflow.com/a/55894599/93105">https://stackoverflow.com/a/55894599/93105</a> for more information</p>
<p>if you want to set the environment variable for the lifetime of the pod then you probably want to set it in the yaml manifest of the pod itself before creating it.</p>
<p>you can also run <code>set</code> if you first run the shell</p>
<pre class="lang-sh prettyprint-override"><code>kubectl exec mypod -- /bin/sh -c 'set'
</code></pre>
