Not able to serve jupyter notebooks in binder

你离开我真会死。 提交于 2019-12-07 08:23:41

问题


Binder project looks promising. It helps in executing notebooks in a github repository by building an executable container. I am trying to build an executable container in binder with the following Dockerfile that has Perl 6 and Python 3 kernels:

FROM sumdoc/perl-6

ENV NB_USER jovyan
ENV NB_UID 1000
ENV HOME /home/${NB_USER}

RUN adduser --disabled-password \
    --gecos "Default user" \
    --uid ${NB_UID} \
    ${NB_USER}


RUN apt-get update \
    && apt-get install -y build-essential \
    git wget libzmq3-dev ca-certificates python3-pip \
    && rm -rf /var/lib/apt/lists/* && pip3 install jupyter notebook --no-cache-dir \
    && zef -v install https://github.com/bduggan/p6-jupyter-kernel.git --force-test \
    && jupyter-kernel.p6 --generate-config





ENV TINI_VERSION v0.16.1
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini 
ENTRYPOINT ["/usr/bin/tini", "--"]
COPY . ${HOME}
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

EXPOSE 8888

CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]

Binder launches this window after building a container:

While trying to run Perl 6 or Python 3 notebook I get this error:

I read this documentation on binder but could not succeed.

What things I am missing? Any help with explanations would be appreciated.


回答1:


After going through this Dockerfile, I solved the issue.

I even wrote a blog on using Perl 6 notebook in Binder here.

What I was missing was to add WORKDIR $HOME after USER ${NB_USER}in my Dockerfile as follows:

FROM sumankhanal/perl-6

ENV NB_USER jovyan
ENV NB_UID 1000
ENV HOME /home/${NB_USER}

RUN adduser --disabled-password \
    --gecos "Default user" \
    --uid ${NB_UID} \
    ${NB_USER}


RUN apt-get update \
    && apt-get install -y build-essential \
    git wget libzmq3-dev ca-certificates python3-pip \
    && rm -rf /var/lib/apt/lists/* && pip3 install jupyter notebook --no-cache-dir \
    && zef -v install https://github.com/bduggan/p6-jupyter-kernel.git --force-test \
    && jupyter-kernel.p6 --generate-config





ENV TINI_VERSION v0.16.1
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini 
ENTRYPOINT ["/usr/bin/tini", "--"]
COPY . ${HOME}
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

WORKDIR ${HOME}

EXPOSE 8888

CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]


来源:https://stackoverflow.com/questions/48079802/not-able-to-serve-jupyter-notebooks-in-binder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!