Last active
November 7, 2016 01:02
-
-
Save knknkn1162/9f997931edf5402d8e158b46aedd6a4e to your computer and use it in GitHub Desktop.
Windows7でJupyterのDockerイメージにbash_kernelを導入するまでのメモ ref: http://qiita.com/knknkn1162/items/30ec5ee4fffa203221e3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerホストマシンを作成する | |
${DOCKER_MACHINE} create -d virtualbox "${VM}" | |
# Docker machineを起動する。2回目以降はここから | |
${DOCKER_MACHINE} start "${VM}" | |
# 環境変数no-proxyの設定 | |
${DOCKER_MACHINE} env --shell=bash --no-proxy ${VM} | |
bash --login -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -f: バックグラウンドで動作 | |
# -N : コマンド実行無し | |
# -L [ローカルマシンで待ち受けるIPアドレス(省略すると,localhost)]:[ローカルPCのポート]:[ターゲットマシンのプライベートIP] (defaultはログインホスト) | |
# Window7だと、ファイアーウォールの画面(下図参照)が出てくるが、アクセス許可しましょう。 | |
$ docker-machine ssh default -f -N -L 8888:127.0.0.1:8888 | |
$ docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
jupyter/datascience-notebook latest 357fc20fb373 2 weeks ago 4.797 GB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMD ["jupyter", "notebook", "--no-browser", "--allow-root"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -p [ホストOS(Linux)のポート番号]:[コンテナ(jupyter)のポート番号] | |
# -d バックグラウンドで立ち上げる。 | |
# コンテナとホストOSのポートマッピングをしましょう.DockerfileでEXPOSE 8888とあるので、ポート番号8888にしてます | |
docker@default:~$ docker run -d -p 8888:8888 jupyter/datascience-notebook | |
ad1cfa7031c04244f1146e5d7f55612131944075e95850091988311933d76d50 | |
Display the running processes of a container | |
# コンテナが稼働した! | |
# 稼働コンテナのプロセス確認(top) | |
docker@default:~$ docker top ad1 # <= ad1はイメージ識別子(一意に判別できさえすれば、途中までで省略可) | |
PID USER COMMAND | |
2407 docker tini -- start-notebook.sh | |
2424 docker {jupyter-noteboo} /opt/conda/bin/python /opt/conda/bin/jupyter-notebook | |
docker@default:~$ docker port ad1 | |
8888/tcp -> 0.0.0.0:8888 # コンテナの8888番ポートがホストの8888番ポートに転送されている | |
docker@default:~$ docker stop ad1 | |
ad1 | |
# 停止中のコンテナを開始すると、runで起動したコンテナ起動の設定がそのまま反映される。 | |
# 例の場合は、-dオプションと-p 8888:8888オプションが反映されるはず! | |
docker@default:~$ docker start ad1 | |
ad1 | |
# psで稼働コンテナを一覧表示できる。やっぱり反映されている。 | |
docker@default:~$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
ad1cfa7031c0 jupyter/datascience-notebook "tini -- start-notebo" 10 minutes ago Up 5 seconds 0.0.0.0:8888->8888/tcp infallible_visvesvaraya |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker run -d -p 8888:8888 -e HTTP_PROXY=${HTTP_PROXY} -e HTTPS_PROXY=${HTTPS_PROXY} -e NO_PROXY=${NO_PROXY} jupyter/datascience-notebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 7d80c442bedbで新規にコンテナを作り直しちゃってます。 | |
docker@default:~$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
7d80c442bedb jupyter/datascience-notebook "tini -- start-notebo" 24 minutes ago Up 24 minutes 0.0.0.0:8888->8888/tcp zen_fermat | |
# -itでインタラクティブにbashと対話できます。execコマンドは新規にプロセスを作成します。 | |
docker@default:~$ docker exec -it 7d8 /bin/bash # <=7d8はイメージ識別子(一意に判別できさえすれば、途中までで省略可) | |
jovyan@7d80c442bedb:~/work$ source activate #anacondaで入れているので、activateして、rootに入ります。(conda install bash_kernelはできないため) | |
(root) jovyan@7d80c442bedb:~/work$ pip install bash_kernel | |
Collecting bash_kernel | |
Downloading bash_kernel-0.4.1-py2.py3-none-any.whl | |
Requirement already satisfied (use --upgrade to upgrade): pexpect>=3.3 in /opt/conda/lib/python3.5/site-packages (from bash_kernel) | |
Installing collected packages: bash-kernel | |
Successfully installed bash-kernel-0.4.1 | |
You are using pip version 8.1.2, however version 9.0.0 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
# 寄り道になるが、素直に従おう(should)じゃないか! | |
(root) jovyan@7d80c442bedb:~/work$ pip install --upgrade pip | |
Collecting pip | |
Downloading pip-9.0.0-py2.py3-none-any.whl (1.3MB) | |
100% |████████████████████████████████| 1.3MB 948kB/s | |
Installing collected packages: pip | |
Found existing installation: pip 8.1.2 | |
Uninstalling pip-8.1.2: | |
Successfully uninstalled pip-8.1.2 | |
Successfully installed pip-9.0.0 | |
(root) jovyan@7d80c442bedb:~/work$ python -m bash_kernel.install | |
Installing IPython kernel spec | |
(root) jovyan@7d80c442bedb:~/work$ exit | |
exit | |
# コンテナの稼働確認 | |
docker@default:~$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
7d80c442bedb jupyter/datascience-notebook "tini -- start-notebo" 20 minutes ago Up 20 minutes 0.0.0.0:8888->8888/tcp zen_fermat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# commitはコンテナ(7d8:jupyter)からイメージ(jupyterbash)を作成する | |
docker@default:~$ docker commit 7d8 jupyterbash/datascience-notebook | |
sha256:ac7319464b50739c010ac7fb56918c28d87a909a2875215533f976bde60226a0 | |
# imageが作成されたかどうか確認 | |
docker@default:~$ docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
jupyterbash/datascience-notebook latest ac7319464b50 6 seconds ago 4.806 GB | |
jupyter/datascience-notebook latest 357fc20fb373 2 weeks ago 4.797 GB | |
docker@default:~$ docker stop 7d8 | |
7d8 | |
# 作成したimageからはいれるかどうかチェック => ブラウザ上でhttp://localhost:8888にアクセスしてOKだった | |
docker@default:~$ docker run -d -p 8888:8888 jupyterbash/datascience-notebook | |
aba0ceba873a3466e8306933aad45858226b4ecdbc8cab7561c267b7da9f7b6a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment