<p>I want to use Kubernetes and the <code>postman/newman</code> Docker image to execute my API tests.</p>
<p>Locally, I can execute the image with</p>
<blockquote>
<p>docker run postman/newman run &lt;url-to-collection&gt; --env-var baseUrl=&lt;local-hostname&gt;</p>
</blockquote>
<p>I include the Image in a Kubernetes manifest file</p>
<pre><code>spec:
  containers:
    - name: newman
      image: postman/newman:latest
      args:
        - run
        - '&lt;url-to-collection&gt;'
        - --env-var baseUrl=&lt;kubernetes-hostname&gt;
</code></pre>
<p>When I apply the manifest and look at the logs of the container, I get the following error:</p>
<p><code>error: unknown option '--global-var baseUrl=&lt;kubernetes-hostname&gt;'</code></p>
<p>I tried out many things with quotes and using the <code>command</code> section instead of the <code>args</code> section, but always with the same result.
I figure that Kubernetes somehow builds the command in a way, that the <code>newman</code> executable can not understand it.
However I could not find any info about that.</p>
<p>(I also created an issue in the GitHub repo of Newman <a href="https://github.com/postmanlabs/newman/issues/2581" rel="nofollow noreferrer">here</a>)</p>
<p>Could anybody explain to me where this problem comes from and how I might solve this?</p>
<p>Thanks anyways!</p>

Simon
<p>Linux commands are made up of a sequence of words.  If you type a command at a shell prompt, it takes responsibility for splitting it into words for you, but in the Kubernetes <code>args:</code> list, you need to split out the words yourself.</p>
<pre class="lang-yaml prettyprint-override"><code>args:
  - run
  - '&lt;url-to-collection&gt;'
  # You want these as two separate arguments, so they need to be
  # two separate list items
  - --env-var
  - baseUrl=&lt;kubernetes-hostname&gt;
</code></pre>
<p>If the two arguments are in the same list item, they are a single &quot;word&quot;:</p>
<pre><code># /bin/ls &quot;/app/some directory/some file&quot;
command:
  - /bin/ls
  # a single argument, including embedded spaces
  - /app/some directory/some file
</code></pre>
<p>The same basic rules apply for Docker Compose <code>entrypoint:</code> and <code>command:</code> and the JSON-syntax Dockerfile <code>ENTRYPOINT</code> and <code>CMD</code> directives, except that the Docker-native forms all also accept a plain string that they will split on spaces (using a shell in the Dockerfile case, but not in the Compose case).</p>
<p>In the <code>docker run</code> command you provide, the shell on your host system processes it first, so the <code>--env-var</code> option and <code>baseUrl=...</code> argument get split into separate words before they're passed into the container.</p>
