0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JupyterLabをdockerでどこででも動かせるようにする

Last updated at Posted at 2020-09-04

手っ取り早くJupyterを動かす

docker run -d --rm -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/jovyan/work -e GRANT_SUDO=yes --user root jupyter/datascience-notebook:$tag start-notebook.sh --NotebookApp.token=password
  • ブラウザから127.0.0.1:8888/labにアクセス。
  • ログイン画面でパスワードを求められたらpasswordと入力する。
  • 終わり

どこからでも動かせるようにする。

run_jupyter_lab
#!/bin/bash
tag=latest
password=password
port=8888

# validate args
if [ $# -gt 1 ]; then
  echo ERROR: the number of args must be 0 or 1
  exit 1
fi

# if a port num is specified, then change the port num
if [ $# -ne 0 ]; then
  port=$1
fi

# the name of running container with port num
name=jl_${port}

# run juypyter lab with port $port
docker run -d --rm -p ${port}:8888 --name ${name} -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/jovyan/work -e GRANT_SUDO=yes --user root jupyter/datascience-notebook:$tag start-notebook.sh --NotebookApp.token=$password

これを~/bin/run_jupyter_labとかに入れておく。ここにはPATHが通っている前提。

run_jupyter_labコマンドを実行すると、実行したディレクトリの名前でdocker containerが動く。notebookがあるディレクトリなんかで実行すると良い。

参考

VSCodeで動かせるようにする

settings.json
{
    "python.pythonPath": "./.venv/bin/python3",
    "python.analysis.extraPaths": [
        "hoge/"
    ],
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 1000,
    "python.linting.lintOnSave": true,
    "python.linting.pylintEnabled": false,
    "python.linting.pycodestyleEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "--ignore=W293, W504",
        "--max-line-length=200",
        "--max-complexity=20"
    ],
    "python.formatting.provider": "autopep8",
    "python.formatting.autopep8Args": [
        "--aggressive",
        "--aggressive"
    ],
    "autoDocstring.docstringFormat": "google",
    "editor.formatOnSave": true
}
pipenv --python 3.8
pipenv install --dev autopep8 flake8 

jupyter使うなら

pipenv install --dev ipykernel

必要そうなライブラリインストール

pipenv install pandas scikit-learn matplotlib
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?