<p>I have a docker Image that basically runs a one time script. That scripts takes 3 arguments. My docker file is </p>

<pre><code>FROM &lt;some image&gt;

ARG URL
ARG USER
ARG PASSWORD

RUN apt update &amp;&amp; apt install curl -y

COPY register.sh .
RUN chmod u+x register.sh

CMD ["sh", "-c", "./register.sh $URL $USER $PASSWORD"]
</code></pre>

<p>When I spin up the contianer using <code>docker run -e URL=someUrl -e USER=someUser -e PASSWORD=somePassword -itd &lt;IMAGE_ID&gt;</code> it works perfectly fine.</p>

<p>Now I want to deploy this as a job.</p>

<p>My basic Job looks like:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: register
spec:
  template:
    spec:
      containers:
      - name: register
        image: registeration:1.0
        args: ["someUrl", "someUser", "somePassword"]
      restartPolicy: Never
  backoffLimit: 4
</code></pre>

<p>But this the pod errors out on </p>

<pre><code>Error: failed to start container "register": Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"someUrl\": executable file not found in $PATH"
</code></pre>

<p>Looks like it is taking my args as commands and trying to execute them. Is that correct ? What can I do to fix this ?</p>

<p>In the Dockerfile as you've written it, two things happen:</p>

<ol>
<li><p>The URL, username, and password are fixed in the image.  Anyone who can get the image can run <code>docker history</code> and see them in plain text.</p></li>
<li><p>The container startup doesn't take any arguments; it just runs the single command with its fixed set of arguments.</p></li>
</ol>

<p>Especially since you're planning to pass these arguments in at execution time, I wouldn't bother trying to include them in the image.  I'd reduce the Dockerfile to:</p>

<pre class="lang-sh prettyprint-override"><code>FROM ubuntu:18.04
RUN apt update \
 &amp;&amp; DEBIAN_FRONTEND=noninteractive \
    apt install --assume-yes --no-install-recommends \
      curl
COPY register.sh /usr/bin
RUN chmod u+x /usr/bin/register.sh
ENTRYPOINT ["register.sh"]
</code></pre>

<p>When you launch it, the Kubernetes <code>args:</code> get passed as command-line parameters to the entrypoint.  (It is the same thing as the Docker Compose <code>command:</code> and the free-form command at the end of a plain <code>docker run</code> command.)  Making the script be the container entrypoint will make your Kubernetes YAML work the way you expect.</p>

<p>In general I prefer using CMD to ENTRYPOINT.  (Among other things, it makes it easier to <code>docker run --rm -it ... /bin/sh</code> to debug your image build.)  If you do that, then the Kubernetes <code>args:</code> need to include the name of the script it's running:</p>

<pre><code>args: ["./register.sh", "someUrl", "someUser", "somePassword"]
</code></pre>
