JupyterHub DockerFiler Set Environment Variable not Work

529 views
Skip to first unread message

Changtao Hou

unread,
Sep 8, 2016, 1:41:25 PM9/8/16
to Project Jupyter
Hi, 

      I try to create a jupyterhub docker container. I setup the JAVA_HOME environment variable in my dockerfile and the docker container build success. But when I use the docker image and found the JAVA_HOME environment variable still need to be set manual. Could anyone help me?
      The dockerfile I used is :

FROM krylov-jupyter-ares
RUN pip install numpy pandas scipy scikit-learn sympy statsmodels && \
    pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps && pip install keras && \
    curl https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl -o /tmp/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl && \
    pip install /tmp/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl

RUN mkdir -p /tools/node && \
    tar xzf node.tar.gz -C /tools/node --strip-components=1 && \
    rm node.tar.gz && \
    /tools/node/bin/npm install -g configurable-http-proxy

RUN pip install jupyterhub && \
    pip install seaborn && \
    pip install matplotlib && \
    pip install xgboost && \
    pip install tqdm

RUN jupyterhub --generate-config && \
    mkdir /data && \
    echo "" | adduser --disabled-password chhou && \
    ln -s /opt/krylov/jupyter/notebooks /home/chhou/notebooks && \
    usermod -aG sudo chhou

RUN echo chhou:password >> /tmp/pw && \
    chpasswd < /tmp/pw && \
    chmod a+rwx /opt/krylov/jupyter/notebooks && \
    chmod -R a+rw /opt/krylov/jupyter/notebooks

EXPOSE 8000

ENV PATH $PATH:/tools/node/bin
ENV JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre

RUN echo "PATH=$PATH" >> /etc/environment && \
         echo "JAVA_HOME=$JAVA_HOME" >> /etc/environment

WORKDIR /opt/krylov/jupyter/notebooks
ENTRYPOINT ["jupyterhub", "--no-ssl"]

         The build command I used is: sudo docker build -f dockerfile .

         Any links or comments will be appreciated.






 

MinRK

unread,
Sep 9, 2016, 7:13:11 AM9/9/16
to Project Jupyter

JupyterHub does not pass all of its environment variables to the single-user servers, because it is likely to include hub-level credentials that the user shouldn’t have access to. For this reason, there is a c.Spawner.env_keep configurable that is a whitelist of environment variables that should be passed down. You can specify that JAVA_HOME should be added with:

c.Spawner.env_keep.append('JAVA_HOME')

in your jupyterhub_config.py


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/4fe6c0b2-5c54-4d59-97a7-5c28470b0f3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages