Dockerを使う

DockerでPython機械学習環境を作る。 以下の記事を参考にする。

dr-asa.hatenablog.com

$ docker run -p 8888:8888 --name ml-container -it asashiho/ml-jupyter-python3

dockerを起動してこのコマンドを打つだけ。 超簡単! これはすごい。 環境構築がめちゃくちゃ楽。

終了はcontrol + C と。

ん、再開はどうしたらいいのか? 一旦閉じると、

http://localhost:8888/?token=<your token>

では当然もうアクセスできない。

$ docker run -p 8888:8888 --name ml-container -it asashiho/ml-jupyter-python3

を再度打つと、error

Error response from daemon: Conflict. The container name "/ml-container" is already in use by container "75a667c2f32b7043e763fdf464d1cc35555f6703e983fd0c8aa99110066468cd". You have to remove (or rename) that container to be able to reuse that name.

コンテナを確認

docker container ls -a
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                   PORTS               NAMES
75a667c2f32b        asashiho/ml-jupyter-python3   "jupyter notebook --…"   3 hours ago         Exited (0) 3 hours ago                       ml-container
fb20782c9075        hello-world                   "/hello"                 4 hours ago         Exited (0) 4 hours ago                       eager_dhawan

これでみると、たしかにいる。

で、restartしてから、再度localhostにアクセスしたらできた。 またnotebookも残っていた。

docker container restart 75a667c2f32b

コマンドはこれ参考にした

qiita.com

他にも参考になりそうな記事
まずはこれ
docs.docker.jp

karaage.hatenadiary.jp

kaggleのkarnelのDocker
amalog.hateblo.jp