<p>I have a docker image that I want to run inside my django code. Inside that image there is an executable that I have written using c++ that writes it's output to google cloud storage. Normally when I run the django code like this:</p>
<pre><code>container = client.V1Container(name=container_name, command=[&quot;//usr//bin//sleep&quot;], args=[&quot;3600&quot;], image=container_image, env=env_list, security_context=security)
</code></pre>
<p>And manually go inside the container to run this:</p>
<pre><code>gcloud container clusters get-credentials my-cluster --region us-central1 --project proj_name  &amp;&amp; kubectl exec pod-id -c jobcontainer -- xvfb-run -a &quot;path/to/exe&quot;
</code></pre>
<p>It works as intended and gives off the output to cloud storage. (I need to use a virtual monitor so I'm using xvfb first). However I must call this through django like this:</p>
<pre><code>container = client.V1Container(name=container_name, command=[&quot;xvfb-run&quot;], args=[&quot;-a&quot;,&quot;\&quot;path/to/exe\&quot;&quot;], image=container_image, env=env_list, security_context=security)
</code></pre>
<p>But when I do this, the job gets created but never finishes and does not give off an output to the storage. When I go inside my container to run <code>ps aux</code> I get this output:</p>
<pre><code>USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   2888  1836 ?        Ss   07:34   0:00 /bin/sh /usr/bin/xvfb-run -a &quot;path/to/exe&quot;
root          16  0.0  1.6 196196 66256 ?        S    07:34   0:00 Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp -auth /tmp/xvfb-run.r5gaBO/Xauthority
root          35  0.0  0.0   7016  1552 ?        Rs   10:31   0:00 ps aux
</code></pre>
<p>It looks like it's stuck inside my code but my code does not have a loop that it can stuck inside, perhaps there is an error occurring (I don't think so since the exact same command is working when typed manually). If there is an error how can I see the console output? Why is my code get stuck and how can I get my desired output? Could there be an error caused by permissions (The code does a lot of stuff that requires permissions like writing to storage and reading files inside the pod, but like mentioned works normally when i run it via the command line)?</p>

<p>Apparently for anyone having a similar issue, we fixed it by adding the command we want to run at the end of the <code>Dockerfile</code> instead of passing it as a parameter inside django's container call like this:</p>
<pre><code>cmd[&quot;entrypoint.sh&quot;]
</code></pre>
<p>entrypoint.sh:</p>
<pre><code>xvfb-run -a &quot;path/to/exe&quot;
</code></pre>
<p>Instead of calling it inside django like we did before and simply removing the command argument from the container call so it looked like this:</p>
<pre><code>container = client.V1Container(name=container_name, image=container_image, env=env_list, stdin=True, security_context=security)
</code></pre>
