[PYTHON] Quickly launch Jupyter with Docker (target language: Anaconda / Ruby)

Purpose of this article

Docker is useful when you want to quickly set up Jupyter locally for analysis or write a simple script. I summarized the method.

The languages handled on Jupyter are Anaconda and Ruby.

Premise

Docker is installed.

When using Anaconda

Use the Docker image officially provided by Jupyter. jupyter/docker-stacks - Github

There are various versions, but this time I will use the datascience-notebook, which contains a set of libraries for analysis.

Since it is local, it will be started with authentication Off. (I think it is better to authenticate when starting on the server) Also, mount Jupyter's work in the current directory so that you can use the data as it is by docker running in the directory containing the data to be analyzed. This will leave the notebook itself local.

docker pull jupyter/datascience-notebook
docker run -d -p 8888:8888 -v "$(pwd):/home/jovyan/work" jupyter/datascience-notebook start-notebook.sh --NotebookApp.token=''

When you access localhost: 8888 from your browser, you can use Anaconda from Jupyter.

Reference Try using Jupyter's Docker image-Qiita

When using Ruby

Although it is not official, I will use the image introduced in this article.

In the case of Ruby, I want to add Gem by myself, so start it with Gemfile and Dockerfile in the directory to docker run.

Gemfile


source 'https://rubygems.org'

gem 'hoge' #Put your favorite gem
gem 'fuga'

Dockerfile


FROM izumin5210/iruby-notebook

ADD Gemfile .
RUN bundle install

Specify only the Ruby character code and start it. Also. As with Anaconda, mount Jupyter's work in the current directory so that you can use the data as it is by docker running in the directory containing the data to be analyzed.

docker build -t=iruby-notebook .
docker run -p 8888:8888 -e RUBYOPT=-EUTF-8 -v "$(pwd):/notebooks" iruby-notebook

If you access localhost: 8888 from your browser, you can use Ruby from Jupyter.

Reference Jupyter Notebook and iRuby for Rails Engineers-Cookpad Developer Blog How to touch Jupyter Notebook without polluting the environment other than Pythonista, or how to touch Ruby with Jupyter Notebook without polluting the environment other than Rubyist --Qiita

that's all.

Recommended Posts

Quickly launch Jupyter with Docker (target language: Anaconda / Ruby)
Until you start Jupyter with Docker
Spark play with WSL anaconda jupyter (2)
Build Jupyter Lab (Python) environment with Docker
Launch environment with LineBot + Heroku + Docker + Python
Launch Flask application with Docker on Heroku
Analytical environment construction with Docker (jupyter notebook + PostgreSQL)