<p>Hello I have a problem with manually running deployment.
I use GitlabCI, dockerfile and kubernetes.</p>
<pre><code>FROM python:3.8

RUN mkdir /app

COPY . /app/

WORKDIR /app

RUN pip install -r requirements.txt

CMD [&quot;python&quot;, &quot;main.py&quot;, &quot;${flag1}&quot;, &quot;${ARG1}&quot;, &quot;${flag2}, &quot;${ARG2}&quot;]
</code></pre>
<p>i need to run my app with command like this &quot;python3 main.py -g argument1 -c argument2&quot;, and every run I need using other arguments. Im using this:
<a href="https://i.stack.imgur.com/6sMOp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6sMOp.png" alt="using this" /></a></p>
<p>Then my pipeline run bash script who check if variable &quot;${ARG1}&quot; is empty, if is empty, then unset &quot;${FLAG1}&quot;. The next step is deploy to kubernetes using standard deployment using gitlabCI.</p>
<p>My idea Is bad because those environment variables aren't passing to Dockerfile. Anybody have some idea? Can't use Dockers build-args because they are don't support &quot;CMD&quot; step.</p>

rupert
<p>You are using the array-syntax for the command (CMD), therefore there is no shell that could expand the variables, but the data is directly used for the <code>exec</code> system call.</p>
<p>If you want the variables to be expaned, use</p>
<pre><code>CMD python main.py ${flag1} ${ARG1} ${flag2} ${ARG2}
</code></pre>
<p>or replace the command completely in kubernetes pod/replica/deployment definition, optionally with variables replaced.</p>
<p>Additional note: The CMD is executed at runtime of the container, not at build time.</p>
