LoginSignup
33
26

More than 3 years have passed since last update.

jupyter を docker で起動後に、token 確認するコマンド

Posted at

初回

jupyter を docker で常時起動する。

docker run -it -d --name jupyter -p 8888:8888 -v $(pwd):/home/jovyan --restart=always -v ~/.config/gcloud:/home/jovyan/gcloud

ログを見て token 取得する。

$ docker logs jupyter
[C 07:06:02.298 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///home/jovyan/.local/share/jupyter/runtime/nbserver-6-open.html
    Or copy and paste one of these URLs:
        http://(e22198a8202b or 127.0.0.1):8888/?token=xxxxxxxxx

上記の http://127.0.0.1:8888/?token=xxxxxxxxx をブラウザで開いて作業開始。

2回目以降

docker 起動しっぱなしなので後日 localhost 開こうとすると token 違うって怒られることがある。こういうときは docker コンテナに入って token 確認しないといけない。

まずコンテナ名確認。

$ docker ps -a
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                    NAMES
e22198a8202b        jupyter/datascience-notebook   "tini -g -- start-no…"   6 weeks ago         Up 3 weeks          0.0.0.0:8888->8888/tcp   jupyter

コンテナに入る。

$ docker exec -it jupyter /bin/bash
jovyan@e22198a8202b:~$

下のコマンドで token 確認する

jovyan@e22198a8202b:~$ jupyter notebook list
Currently running servers:
http://0.0.0.0:8888/?token=yyyy :: /home/jovyan
jovyan@e22198a8202b:~$ exit

http://0.0.0.0:8888/?token=yyyy を開いて作業再開。

33
26
3

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
33
26