title: How do i have a JAVA_HOME set using a Dockerfile and python?
body: <p>I am trying to set up a Dockerfile for my project and am unsure how to set a JAVA_HOME within the container.</p>
  
  <pre><code>FROM python:3.6
  # Set the working directory to /app
  WORKDIR /app
  # Copy the current directory contents into the container at /app
  COPY . /app
  # Install any needed packages specified in requirements.txt
  RUN pip install --trusted-host pypi.python.org -r requirements.txt
  # Define environment variable
  ENV NAME Netflow
  # Run netflow.py
  CMD ["python", "netflow.py"]
  </code></pre>
  
  <p>In the requirements.txt I have...</p>
  
  <pre><code>numpy
  pandas
  kafka
  pyspark
  log
  </code></pre>
  
  <p>My netflow.py file is...</p>
  
  <pre><code>import pandas, math, re, log
  from pyspark import SparkConf, SparkContext
  from pyspark.sql import SQLContext
  
  
  conf = SparkConf().setAppName("building a warehouse")
  sc = SparkContext(conf=conf)
  df=pandas.read_csv(r'TestDataSet.csv') 
  </code></pre>
  
  <p>The output in the terminal after trying to run it is....</p>
  
  <pre><code>JAVA_HOME is not set
  Traceback (most recent call last):
    File "netflow.py", line 7, in &lt;module&gt;
      sc = SparkContext(conf=conf)
    File "/usr/local/lib/python3.6/site-packages/pyspark/context.py", line 115, in __init__
      SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    File "/usr/local/lib/python3.6/site-packages/pyspark/context.py", line 298, in _ensure_initialized
      SparkContext._gateway = gateway or launch_gateway(conf)
    File "/usr/local/lib/python3.6/site-packages/pyspark/java_gateway.py", line 94, in launch_gateway
      raise Exception("Java gateway process exited before sending its port number")
  </code></pre>
  
  <p>I have been looking for a solution but none have worked so far. </p>
  
  <p>I have tried </p>
  
  <pre><code>ENV JAVA_HOME /Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
  </code></pre>
  
  <p>and I have tried using a separate command </p>
  
  <pre><code>docker run -e "JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home" project env
  </code></pre>
  
  <p>I am still getting the same error</p>