#Dockerでjupyter notebookを動かした時の備忘録
環境
- MacOS(10.15.3)
- docker for mac(2.3.0.3)
流れ
まずはDockerfileの作成
mkdir ~/jupyter
cd ~/jupyter
touch Dockerfile
vim Dockerfile
Dockerfile
FROM python:3
USER root
RUN apt update && \
apt -y install jupyter-notebook
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
ENV TZ JST-9
CMD ["jupyter-notebook", "--port", "8000", "--ip=0.0.0.0", "--allow-root"]
dockerのビルド
docker build -t jupyter .
dockerコンテナ起動
docker run --rm -p 8001:8000 jupyter
動く
http://127.0.0.1:8001/?token=~
につなげるとjupyter notebookが動く
rubyを動かせる様にする
irubyが必要なためDockerfileを修正する
Dockerfile
FROM python:3
USER root
RUN apt update && \
apt -y install jupyter-notebook ruby ruby-ffi-rzmq && \
gem install iruby && \
iruby register --force
ENV LANG ja_JP.UTF-8
ENV LANGUAGE ja_JP:ja
ENV LC_ALL ja_JP.UTF-8
ENV TZ JST-9
CMD ["jupyter-notebook", "--port", "8000", "--ip=0.0.0.0", "--allow-root"]
jupyter notebookでrubyが動く
jupyter notebookのnewからrubyが選べる様になる
-> 動く。やったー
その他
ruby-ffi-rzmq
がないと下記エラー発生
[I 15:26:42.550 NotebookApp] Kernel started: 70bcadba-f259-40b4-9fd0-1ea479195b0e
F, [2020-06-07T15:26:43.232174 #9] FATAL -- : Kernel died: uninitialized constant IRuby::SessionAdapter::PyzmqAdapter::PyCall
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter/pyzmq_adapter.rb:7:in `rescue in load_requirements'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter/pyzmq_adapter.rb:4:in `load_requirements'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:7:in `available?'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:63:in `block in select_adapter_class'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:62:in `each_value'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:62:in `select_adapter_class'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session.rb:112:in `create_session_adapter'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session.rb:12:in `initialize'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:17:in `new'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:17:in `initialize'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `new'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `run_kernel'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:40:in `run'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/bin/iruby:5:in `<top (required)>'
/usr/local/bin/iruby:23:in `load'
/usr/local/bin/iruby:23:in `<main>'
Traceback (most recent call last):
15: from /usr/local/bin/iruby:23:in `<main>'
14: from /usr/local/bin/iruby:23:in `load'
13: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/bin/iruby:5:in `<top (required)>'
12: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:40:in `run'
11: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `run_kernel'
10: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `new'
9: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:17:in `initialize'
8: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:17:in `new'
7: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session.rb:12:in `initialize'
6: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session.rb:112:in `create_session_adapter'
5: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:62:in `select_adapter_class'
4: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:62:in `each_value'
3: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:63:in `block in select_adapter_class'
2: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter.rb:7:in `available?'
1: from /var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter/pyzmq_adapter.rb:4:in `load_requirements'
/var/lib/gems/2.5.0/gems/iruby-0.4.0/lib/iruby/session_adapter/pyzmq_adapter.rb:7:in `rescue in load_requirements': uninitialized constant IRuby::SessionAdapter::PyzmqAdapter::PyCall (NameError)