title: Python subprocess.Popen() not working in a docker container - works fine locally
body: <p>I have created a Django REST framework project that I want to deploy on a server. I do not have admin access to the server, and so, the only way I found to ensure that all the project dependencies (such as Anaconda distribution) will be available on the server, is to create a docker image for my project , then create a corresponding container on the server, then run it from there.</p>
  
  <p>In my project, I have a python script (mymain.py) that gets called using subprocess.Popen().
  This works fine locally, and subprocess.Popen() does everything it is supposed to do.</p>
  
  <p>However, when I try to do it from the docker container, it seems as if the line subprocess.Popen() was completely skipped [mymain.py is not called].</p>
  
  <p>For docker, I have created a docker-compose.yml file, and in command prompt I type:</p>
  
  <pre><code>docker-compose up
  </code></pre>
  
  <p>I do not see any error, and everything seem to be working fine, however subprocess.Popen() does not seem to be working.</p>
  
  <p>mymain.py first line is:</p>
  
  <pre><code>print('Testing if subprocess called mymain.py!!!')  
  </code></pre>
  
  <p>In a different file, I call subprocess.Popen(). 
  I tried printing out the error, but unfortunately, both stdout and stderr return nothing:</p>
  
  <pre><code>p = subprocess.Popen(['python', mymain_path, args], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 
  out, err = p.communicate()
  print('SUBPROCESS ERROR: ' + str(err))
  print('SUBPROCESS stdout: ' + str(out.decode()))    
  </code></pre>
  
  <p>And this is what I get:</p>
  
  <pre><code>SUBPROCESS ERROR: None
  SUBPROCESS stdout:
  </code></pre>
  
  <p>As you can see, the first line of my main.py was never printed...  </p>
  
  <p>However, when I do this locally by typing in command prompt:</p>
  
  <pre><code>python manage.py runserver 9000
  </code></pre>
  
  <p>everything works with no issues (the line 'Testing if subprocess called mymain.py!!!' gets printed).</p>
  
  <p>I even tried to open the docker container shell and type the same 'python manage.py runserver 9000' command in there, but that did not work unfortunately.</p>
  
  <p>Now the question is, how do I get subprocess to work remotely (in a docker container)? </p>
  
  <p>Any help on this is very appreciated!</p>
  
  <p>I am using:</p>
  
  <pre><code>Docker version 18.09.2, build 6247962
  docker-compose version 1.23.2, build 1110ad01
  Python 3.7.0
  </code></pre>