<p>I have a executed  <code>command1 | command2</code>  which runs from inside a container.</p>
<p>I am trying to run the same command by passing it to the running container, but it doesn't work.
I tried <code>kubectl -n namespace exec -it pod -- 'command1 | command2'</code></p>
<p>Any ideas? If pipes are not supported, any alternatives to run these 2 commands in sequence ?</p>

USR
<p>The arguments to the <code>kubectl exec</code> command are executed directly, without a shell. Because you're passing not a single command but a shell expression, this isn't going to work.</p>
<p>The solution is to explicitly invoke the shell:</p>
<pre><code>kubectl -n namespace exec -it pod -- sh -c 'command1 | command2'
</code></pre>
<p>For example:</p>
<pre><code>$ kubectl exec -it fedora0 -- sh -c 'echo hello world | sed s/hello/goodbye/'
goodbye world
</code></pre>
