Skip to content

Commit

Permalink
Jupyter Lab in a Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
taroyabuki committed Apr 19, 2024
1 parent 9bcbaf0 commit 4e3e6c1
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Jupyter LabのためのDockerコンテナ

Dockerが動作する環境を前提とします.

注意:macOSでも動作を確認していますが,2024年4月の時点で,Dockerイメージwolframresearch/wolframengineのプラットフォームがlinux/amd64だけでなので,性能は悪いかもしれません.

## 目標

Python, R, Wolfram言語が使えるJupyter Labを,Dockerコンテナで提供します.

コンテナを構築は次のように構築できるようになります(`pass`はパスワード(変更可).Ctrl-Cで終了).

```bash
docker run --rm -it -v $(pwd):/home/wolframengine/work -e PASS=pass -p 8888:8888 comath
```

ブラウザでhttp://localhost:8888 にアクセスして使えるようになります(計算が途中で止まったようにみえるときは,Kernel→Restart Kernel).

![Jupyter Lab](jupyterlab.png)

/home/wolframengine/work に保存したファイルはホストに保存されるようになります.

## 準備

### Wolfram Engineの有効化

Wolfram IDがない場合は https://account.wolfram.com/login/create で作ってから先に進みます.

Wolfram Engineを有効化して,Licensing/mathpassを作ります.そのために,適当な作業ディレクトリで,次を実行します.

```bash
mkdir Licensing
docker run -it wolframresearch/wolframengine
```

Wolfram IDとパスワードを入力すると有効化されます(参考:https://hub.docker.com/r/wolframresearch/wolframengine ).

```
> docker run -it wolframresearch/wolframengine
The Wolfram Engine requires one-time activation on this computer.
Visit https://wolfram.com/developer-license to get your free license.
Wolfram ID: [email protected]
Password:
Wolfram Engine activated. See https://www.wolfram.com/wolframscript/ for more information.
Wolfram Language 12.2.0 Engine for Linux x86 (64-bit)
Copyright 1988-2020 Wolfram Research, Inc.
In[1]:= $PasswordFile
Out[1]= /home/wolframengine/.WolframEngine/Licensing/mathpass
In[2]:= $PasswordFile // FilePrint
1e1d781ed0a3 6520-03713-97466 4304-2718-2K5ATR 5095-179-696:2,0,8,8:80001:20190627
In[3]:= Quit
```

テキストファイルLicensing/mathpassを作り,`In[2]`の結果,上の例では`1e1d...627`を貼り付けて保存します.

ディレクトリ構造は次のとおりです.

```
.
└── Licensing
└── mathpass
```

Wolfram Engineの動作を確認します(`Quit`で終了).

```bash
docker run --rm -it -v ./Licensing:/usr/share/WolframEngine/Licensing wolframresearch/wolframengine
```

## イメージ構築

Python, R, Wolfram Engineを使えるJupyter LabのDockerイメージを構築します([Dockerfile](https://raw.githubusercontent.com/taroyabuki/comath/main/docker/Dockerfile)).

```bash
docker run --rm curlimages/curl https://raw.githubusercontent.com/taroyabuki/comath/main/docker/Dockerfile \
| docker build -t comath -f- .
```

補足:aptのプロキシがある環境では,次のようにプロキシを指定します.

```bash
docker run --rm curlimages/curl https://raw.githubusercontent.com/taroyabuki/comath/main/docker/Dockerfile \
| docker build -t comath --build-arg APT_PROXY=http://10.100.192.10:3142 -f- .
```
Binary file added docker/jupyterlab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e3e6c1

Please sign in to comment.