wielandbrendel / agmb-docker

Docker images for scientific computing and deep learning - by AG Bethge
7 stars 4 forks source link

Integrate with jupyter/notebook with jupyter-nodejs #29

Closed jan-osch closed 8 years ago

jan-osch commented 8 years ago

Hi ! I have been working on creating a docker image that would integrate jupyter/notebook with a node-js kernel. I am beginner in both jupyter and docker, so it is challenging for me.

I managed to install everything and get the notebook running. Jupyter recognizes the Node.js kernel but when I open a new notebook with it i get kernel error and a stacktrace like this:

[I 10:50:04.088 NotebookApp] Creating new notebook in
[I 10:50:04.095 NotebookApp] Writing notebook-signing key to /home/docker/.local/share/jupyter/notebook_secret
[W 10:50:04.811 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20160121104947 (10.163.12.72) 5.50ms referer=http://1
0.177.62.126:8888/notebooks/Untitled.ipynb?kernel_name=nodejs
[E 10:50:05.215 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/usr/src/jupyter-notebook/notebook/base/handlers.py", line 458, in wrapper
        result = yield gen.maybe_future(method(self, *args, **kwargs))
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 1008, in run
        value = future.result()
      File "/usr/local/lib/python3.4/dist-packages/tornado/concurrent.py", line 232, in result
        raise_exc_info(self._exc_info)
      File "<string>", line 3, in raise_exc_info
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 1014, in run
        yielded = self.gen.throw(*exc_info)
      File "/usr/src/jupyter-notebook/notebook/services/sessions/handlers.py", line 58, in post
        sm.create_session(path=path, kernel_name=kernel_name))
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 1008, in run
        value = future.result()
      File "/usr/local/lib/python3.4/dist-packages/tornado/concurrent.py", line 232, in result
        raise_exc_info(self._exc_info)
      File "<string>", line 3, in raise_exc_info
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 1014, in run
        yielded = self.gen.throw(*exc_info)
      File "/usr/src/jupyter-notebook/notebook/services/sessions/sessionmanager.py", line 73, in create_session
        self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 1008, in run
        value = future.result()
      File "/usr/local/lib/python3.4/dist-packages/tornado/concurrent.py", line 232, in result
        raise_exc_info(self._exc_info)
      File "<string>", line 3, in raise_exc_info
      File "/usr/local/lib/python3.4/dist-packages/tornado/gen.py", line 282, in wrapper
        yielded = next(result)
      File "/usr/src/jupyter-notebook/notebook/services/kernels/kernelmanager.py", line 87, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "/usr/local/lib/python3.4/dist-packages/jupyter_client/multikernelmanager.py", line 109, in start_kernel
        km.start_kernel(**kwargs)
      File "/usr/local/lib/python3.4/dist-packages/jupyter_client/manager.py", line 244, in start_kernel
        **kw)
      File "/usr/local/lib/python3.4/dist-packages/jupyter_client/manager.py", line 190, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "/usr/local/lib/python3.4/dist-packages/jupyter_client/launcher.py", line 123, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
        raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: ''

This is my Dockerfile. Could you share some insights what am I doing wrong?

#jupyter node.js + python2 + python3 as docker container
FROM jupyter/notebook

RUN apt-get update && apt-get install -y python2.7
WORKDIR /tmp
RUN apt-get install -y wget

RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python2.7 get-pip.py

RUN apt-get install -y git git-core

RUN wget https://nodejs.org/download/release/v0.12.9/node-v0.12.9-linux-x64.tar.gz
RUN tar xzf node-v0.12.9-linux-x64.tar.gz
RUN sudo cp -rp node-v0.12.9-linux-x64 /usr/local/
RUN sudo ln -s /usr/local/node-v0.12.9-linux-x64 /usr/local/node
ENV PATH /usr/local/node/bin:$PATH

RUN echo "echo \$USER \$USER_NAME \$USER_HOME" >> /usr/local/bin/run
RUN echo "lastUser=\$(tail -1 /etc/passwd | cut -d: -f1)" >> /usr/local/bin/run
RUN echo "'last user' \$lastUser"
RUN echo "su -c 'jupyter notebook --ip=0.0.0.0 --no-browser --notebook-dir=\$USER_HOME' \$lastUser" >> /usr/local/bin/run

RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
USER docker
WORKDIR /home/docker

RUN mkdir -p  /home/docker/.ipython/kernels/nodejs
RUN wget https://github.com/notablemind/jupyter-nodejs/releases/download/v1.1.0/jupyter-nodejs-1.1.0.tgz
RUN tar xf jupyter-nodejs-1.1.0.tgz
WORKDIR /home/docker/package
RUN npm install && node install.js

EXPOSE 8888

ENTRYPOINT ["tini", "--"]

CMD bash -C '/usr/local/bin/run'
jan-osch commented 8 years ago

Ok. Fixed: Working Dockerfile

#jupyter node.js + python2 + python3 as docker container
FROM jupyter/notebook

# install wget
RUN apt-get update
RUN apt-get install -y wget

# install nodejs
WORKDIR /tmp
RUN wget https://nodejs.org/download/release/v0.12.9/node-v0.12.9-linux-x64.tar.gz
RUN tar xzf node-v0.12.9-linux-x64.tar.gz
RUN sudo cp -rp node-v0.12.9-linux-x64 /usr/local/
RUN sudo ln -s /usr/local/node-v0.12.9-linux-x64 /usr/local/node
ENV PATH /usr/local/node/bin:$PATH

#install jupyter-nodejs
RUN mkdir -p  $HOME/.ipython/kernels/nodejs
RUN wget https://github.com/notablemind/jupyter-nodejs/releases/download/v1.1.0/jupyter-nodejs-1.1.0.tgz
RUN tar xf jupyter-nodejs-1.1.0.tgz
WORKDIR /tmp/package
RUN npm install && node install.js
wielandbrendel commented 8 years ago

@jan-osch I am happy to hear that you are using jupyter-notebook and got node.js running. Might be interesting for some other people as well.

One note of caution: the containers are not completely stabilized yet, we are still fixing problems and errors (as you might have noticed). It will take a couple more days.