LoginSignup
0
1

More than 3 years have passed since last update.

Jupyterhubで教室を作る

Last updated at Posted at 2020-01-19

Jupyterhubのことがようやく少しわかってきました。

皆様はJupyterhubという最強のPython実行環境を使っているでしょうか?

Kaggleなどもありますが自分が持っているサーバーインスタンス上でJupyterhubを動かすことができれば結構便利です。

将来的にはトレーニングなどで使えないかなと思いJupyterhubでの運用方法を模索していました。

その中で特にユーザーの作り方ユーザーがログインしたときのホームディレクトリを設定する方法がわからなかったので共有します。

まずはJupyterhubのインストール

$ pip install jupyterhub

Jupyterhubのデーモン化(起動しっぱなしにする)

#外部からアクセスできるようにホストも設定
$ nohup jupyterhub --ip=0.0.0.0 >> jupyterhub.log 2>&1 &

CONFIGをつくる

jupyterhub_config.pyというファイルが作られます。

$ jupyterhub --generate-config

ユーザーのホワイトリストの設定

ホワイトリストのユーザー名しかうけつけないようにします。

jupyterhub_config.py
c.Authenticator.whitelist = {'【ユーザー名】'}

ユーザーごとのホームディレクトリの設定

{username}でログインしたユーザーネームで可変になるように設定します。ユーザーごとの最上位のディレクトリを設定します。Jupyterhubではユーザーのディレクトリを作ってくれないので自分で作っておくことをお忘れなく。

jupyterhub_config.py
c.Spawner.notebook_dir = '/home/【ユーザー名】/jupyterhub/{username}'

更新履歴

  • 2020/01/19 新規作成
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1