title: Error while calling python subprocess in docker container
body: <p>I'm trying to call a subprocess in python 2.7. This subprocess executes a JAVA jar file and reads the output. I'm using django in a docker container.</p>
  
  <p>I'm calling a function:</p>
  
  <pre><code>def call_exec(lang)
    curdir = curdir = 'ht/exec_folder'
    tmp_files_dir = 'ht/temp_files'
    script_args = ["java","-jar",'/'+curdir + "/executable.jar",
          "-l",lang,"-s",'/'+tmp_files_dir]
    output = subprocess.check_output(script_args)
    return output
  </code></pre>
  
  <p>Here, ht is a folder inside my Django app. I'm trying to use executable.jar and read the output. The other arguments are meant for running the executable.
  The following is the error produced:</p>
  
  <pre><code>django_1    |     similarity = call_exec('english')
  django_1    |   File "/app/langswipe/submissions/check_view.py", line 80, in call_exec
  django_1    |     output = subprocess.check_output(script_args)
  django_1    |   File "/usr/local/lib/python2.7/subprocess.py", line 567, in check_output
  django_1    |     process = Popen(stdout=PIPE, *popenargs, **kwargs)
  django_1    |   File "/usr/local/lib/python2.7/subprocess.py", line 711, in __init__
  django_1    |     errread, errwrite)
  django_1    |   File "/usr/local/lib/python2.7/subprocess.py", line 1343, in _execute_child
  django_1    |     raise child_exception
  django_1    | OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>There are 2 files in the tmp_files_dir. When I run the executable on my local machine, the same arguments give me a result but this one does not. Any clue on what's happening ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The jar is in place but the subprocess call fails. Locally, it's running fine. With comments from experienced professionals, I took a look at the docker file and I realized that Java was missing inside the container. I tried installing Java on this container but the build failed.</p>
  
  <p>I read the following sources to install JAVA on my present container:</p>
  
  <p><a href="https://stackoverflow.com/questions/36587850/best-way-to-install-java-8-using-docker">Best way to install java 8 using docker?</a></p>
  
  <p><a href="https://www.ivankrizsan.se/2015/08/08/creating-a-docker-image-with-ubuntu-and-java/" rel="nofollow noreferrer">https://www.ivankrizsan.se/2015/08/08/creating-a-docker-image-with-ubuntu-and-java/</a></p>
  
  <p><a href="https://raw.githubusercontent.com/docker-library/openjdk/e6e9cf8b21516ba764189916d35be57486203c95/8-jdk/Dockerfile" rel="nofollow noreferrer">https://raw.githubusercontent.com/docker-library/openjdk/e6e9cf8b21516ba764189916d35be57486203c95/8-jdk/Dockerfile</a></p>
  
  <p>My modified docker file is :</p>
  
  <pre><code>FROM python:2.7
  ENV PYTHONUNBUFFERED 1
  
  # to accomodate slate
  RUN easy_install distribute
  
  # Requirements have to be pulled and installed here, otherwise caching won't work
  COPY ./requirements /requirements
  
  RUN pip install -r /requirements/production.txt &amp;&amp; \
      mkdir -p /usr/share/nltk_data &amp;&amp; \
      python -m nltk.downloader -d /usr/share/nltk_data punkt stopwords wordnet averaged_perceptron_tagger &amp;&amp; \
      apt-get update &amp;&amp; apt-get install poppler-utils -qy
  
  
  
  RUN groupadd -r django &amp;&amp; useradd -r -g django django
  COPY . /app
  RUN chown -R django /app
  
  COPY ./compose/django/gunicorn.sh /gunicorn.sh
  COPY ./compose/django/entrypoint.sh /entrypoint.sh
  RUN sed -i 's/\r//' /entrypoint.sh
  RUN sed -i 's/\r//' /gunicorn.sh
  RUN chmod +x /entrypoint.sh &amp;&amp; chown django /entrypoint.sh
  RUN chmod +x /gunicorn.sh &amp;&amp; chown django /gunicorn.sh
  
  
  RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends \
          bzip2 \
          unzip \
          xz-utils \
      &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  RUN echo 'deb http://deb.debian.org/debian jessie-backports main' &gt; /etc/apt/sources.list.d/jessie-backports.list
  
  # Default to UTF-8 file.encoding
  ENV LANG C.UTF-8
  
  # add a simple script that can auto-detect the appropriate JAVA_HOME value
  # based on whether the JDK or only the JRE is installed
  RUN { \
          echo '#!/bin/sh'; \
          echo 'set -e'; \
          echo; \
          echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
      } &gt; /usr/local/bin/docker-java-home \
      &amp;&amp; chmod +x /usr/local/bin/docker-java-home
  
  ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
  
  ENV JAVA_VERSION 8u111
  ENV JAVA_DEBIAN_VERSION 8u111-b14-2~bpo8+1
  
  # see https://bugs.debian.org/775775
  # and https://github.com/docker-library/java/issues/19#issuecomment-70546872
  ENV CA_CERTIFICATES_JAVA_VERSION 20140324
  
  RUN set -x \
      &amp;&amp; apt-get update \
      &amp;&amp; apt-get install -y \
          openjdk-8-jdk="$JAVA_DEBIAN_VERSION" \
          ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
      &amp;&amp; rm -rf /var/lib/apt/lists/* \
      &amp;&amp; [ "$JAVA_HOME" = "$(docker-java-home)" ]
  
  # see CA_CERTIFICATES_JAVA_VERSION notes above
  RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
  
  
  
  
  WORKDIR /app
  
  ENTRYPOINT ["/entrypoint.sh"]
  </code></pre>
  
  <p>The build fails. I have very limited knowledge of docker as I am new to it and I would appreciate if someone helped me figure out the problem. </p>