{"id":1381,"date":"2023-02-28T12:13:40","date_gmt":"2023-02-28T03:13:40","guid":{"rendered":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/?p=1381"},"modified":"2023-03-24T10:08:33","modified_gmt":"2023-03-24T01:08:33","slug":"post-1381","status":"publish","type":"post","link":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/archives\/1381","title":{"rendered":"JupyterNotebook\u3092\u4f7f\u3046"},"content":{"rendered":"<h2>\u79c1\u306e3\u901a\u308a\u306eR\u306e\u4f7f\u3044\u65b9<\/h2>\n<h3>Windows\u306eRGui<\/h3>\n<h4>\u826f\u3044\u3068\u3053\u308d<\/h4>\n<p>\u30b0\u30e9\u30d5(\u753b\u50cf)\u304c\u305d\u306e\u5834\u3067\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<h4>\u60aa\u3044\u3068\u3053\u308d<\/h4>\n<p>\u30d8\u30eb\u30d7\u304c\u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u8868\u793a\u3055\u308c\u308b(\u898b\u308b\u305f\u3073\u306b\u30bf\u30d6\u304c\u5897\u3048\u3066\u3044\u304f)\u3002Linux\u3067\u89e3\u6790\u3057\u305f\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u306e\u304c\u9762\u5012(SCP\u3068\u304b\u30a6\u30a7\u30d6\u7d4c\u7531\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3068\u304b)\u3002<\/p>\n<h3>Linux\u306bSSH\u3067\u63a5\u7d9a\u3057\u3066R<\/h3>\n<h4>\u826f\u3044\u3068\u3053\u308d<\/h4>\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u81ea\u52d5\u5b9f\u884c\u3067\u304d\u308b(Rscript)\u3002\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u8d77\u52d5\u3059\u308b\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9(PostgreSQL)\u3068\u9023\u643a\u3057\u3084\u3059\u3044\u3002<\/p>\n<h4>\u60aa\u3044\u3068\u3053\u308d<\/h4>\n<p>\u56f3\u3092\u8868\u793a\u3067\u304d\u306a\u3044\u3002<\/p>\n<h3>Linux\u3067JupyterNotebook\u3092\u8d77\u52d5\u3057\u3001Windows\u304b\u3089\u30d6\u30e9\u30a6\u30b6\u30fc\u7d4c\u7531\u3067\u4f7f\u3046<\/h3>\n<h4>\u826f\u3044\u3068\u3053\u308d<\/h4>\n<p>\u30b3\u30fc\u30c9(\u89e3\u6790\u624b\u9806)\u3068\u56f3\u3068\u8aac\u660e\u30fb\u8003\u5bdf\u3092\u4e00\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u307e\u3068\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h4>\u60aa\u3044\u3068\u3053\u308d<\/h4>\n<p>\u74b0\u5883\u69cb\u7bc9\u304c\u9762\u5012\u3002<\/p>\n<h2>Docker\u3092\u4f7f\u3063\u3066JupyterNotebook\u3092\u8d77\u52d5\u3059\u308b<\/h2>\n<p>JupyterNotebook\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001python\u3068\u304b\u3001anaconda\u3068\u304b\u3001pip\u3068\u304b\u304c\u5fc5\u8981\u306b\u306a\u308a\u3001\u305d\u308c\u3089\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u305d\u308d\u3048\u305f\u308a\u3068\u3001\u5358\u306b\u624b\u9593\u304c\u304b\u304b\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u73fe\u5b58\u306e\u74b0\u5883\u3068\u4e0d\u6574\u5408\u3092\u8d77\u3053\u3057\u305f\u308a\u3057\u307e\u3059\u3002<br \/>\n\u305d\u3053\u3067Docker\u3092\u5229\u7528\u3057\u307e\u3059\u3002JupyterNotebook\u3092\u52d5\u304b\u3059\u305f\u3081\u306e\u74b0\u5883\u304c\u6574\u3063\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u4f7f\u3048\u3070\u3001\u4ed6\u306e\u30bd\u30d5\u30c8\u3068\u306e\u7af6\u5408\u3082\u767a\u751f\u3059\u308b\u3053\u3068\u306a\u304f\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>Docker\u30a4\u30e1\u30fc\u30b8\u3092\u63a2\u3059<\/h3>\n<pre class=\"code\"># docker search jupyter\nINDEX       NAME                                           DESCRIPTION                                     STARS\ndocker.io   docker.io\/jupyter\/datascience-notebook         Data Science Jupyter Notebook Python Stack...   980\n(\u4ee5\u4e0b\u7701\u7565)\n<\/pre>\n<p>\u4e00\u756a\u4e0a\u306e docker.io\/jupyter\/datascience-notebook \u3092\u4f7f\u3063\u3066\u307f\u308b\u3002<\/p>\n<h3>Docker\u30a4\u30e1\u30fc\u30b8\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h3>\n<pre class=\"code\"># docker pull docker.io\/jupyter\/datascience-notebook<\/pre>\n<h3>Docker\u30b3\u30f3\u30c6\u30ca\u306e\u8d77\u52d5<\/h3>\n<p>\u30a4\u30e1\u30fc\u30b8\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u3057\u3066\u5b9f\u969b\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u74b0\u5883\u3092\u3064\u304f\u308b\u3002<\/p>\n<pre class=\"code\"># docker run -d --name mynote docker.io\/jupyter\/datascience-notebook\n# docker logs mynote\n(\u9014\u4e2d\u7701\u7565)\n[C 06:22:30.186 NotebookApp]\n    To access the notebook, open this file in a browser:\n        file:\/\/\/home\/jovyan\/.local\/share\/jupyter\/runtime\/nbserver-8-open.html\n    Or copy and paste one of these URLs:\n        http:\/\/edfb3dfc0f44:8888\/?token=69989a8a1be58d22b013b6223f69cdb602344fe1ab4bb290\n     or http:\/\/127.0.0.1:8888\/?token=69989a8a1be58d22b013b6223f69cdb602344fe1ab4bb290\n<\/pre>\n<p>docker run\u306b-d\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u3066\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u5b9f\u884c\u3055\u305b\u308b\u3002&#8211;name\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30b3\u30f3\u30c6\u30ca\u306b\u540d\u524d\u3092\u3064\u3051\u308b\u3002<br \/>\ndocker logs \u3067Jupyter\u306e\u30ed\u30b0\u3092\u51fa\u529b\u3055\u305b\u3001\u63a5\u7d9a\u306b\u5fc5\u8981\u306a\u60c5\u5831(http:\/\/127&#8230;.)\u3092\u5f97\u308b\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u3053\u306e\u307e\u307e\u3067\u306fjupyter\u306b\u63a5\u7d9a\u3067\u304d\u306a\u3044\u3002jupyter\u304c\u52d5\u3044\u3066\u3044\u308b(\u5f85\u3061\u53d7\u3051\u3066\u3044\u308b)\u30dd\u30fc\u30c8\u304c8888\u3067\u3042\u308b\u304c\u3001\u3053\u308c\u306fdocker\u306e\u30b3\u30f3\u30c6\u30ca\u304c\u63d0\u4f9b\u3059\u308b\u30dd\u30fc\u30c8\u3067\u3001\u5916\u304b\u3089\u63a5\u7d9a\u3067\u304d\u306a\u3044\u305f\u3081\u3067\u3042\u308b\u3002\u30b3\u30f3\u30c6\u30ca\u5185\u306e\u30dd\u30fc\u30c8\u306b\u63a5\u7d9a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u306f\u30db\u30b9\u30c8\u30de\u30b7\u30f3\u306e\u30dd\u30fc\u30c8\u306b\u3064\u306a\u3050\u5fc5\u8981\u304c\u3042\u308b\u3002<br \/>\n\u4e00\u65e6\u30b3\u30f3\u30c6\u30ca\u3092\u524a\u9664\u3057\u3001-p\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u3066\u30b3\u30f3\u30c6\u30ca\u3092\u4f5c\u308a\u76f4\u3059\u3002<\/p>\n<pre class=\"code\"># docker stop mynote\n# docker rm mynote\n# docker run -d --name mynote -p 10080:8888 docker.io\/jupyter\/datascience-notebook\n# docker logs mynote\n(\u9014\u4e2d\u7701\u7565)\n     or http:\/\/127.0.0.1:8888\/?token=901472142b49b5a072a3b66e3320c6bf47ad199c11687b64\n<\/pre>\n<p>jupyter\u306e\u8d77\u52d5\u78ba\u8a8d\u306e\u305f\u3081\u306bcurl\u3067\u63a5\u7d9a\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"code\">$ curl -D - \"http:\/\/127.0.0.1:10080\/?token=901472142b49b5a072a3b66e3320c6bf47ad199c11687b64\"\nHTTP\/1.1 302 Found\nServer: TornadoServer\/6.1\nContent-Type: text\/html; charset=UTF-8\nDate: Mon, 27 Feb 2023 08:39:45 GMT\nLocation: \/tree?token=901472142b49b5a072a3b66e3320c6bf47ad199c11687b64\nContent-Length: 0\n<\/pre>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306b\u8fd4\u3063\u3066\u3053\u308c\u3070jupyter\u306f\u8d77\u52d5\u3057\u3066\u3044\u308b\u306e\u3067\u3001127.0.0.1\u3092Linux\u306eIP\u30a2\u30c9\u30ec\u30b9\u306b\u5909\u66f4\u3057\u3066\u5916\u90e8\u304b\u3089\u63a5\u7d9a\u3067\u304d\u308b\u306f\u305a\u3002\u3082\u3057\u63a5\u7d9a\u3067\u304d\u306a\u3051\u308c\u3070\u3001linux\u306e\u30d5\u30a1\u30a4\u30a2\u30a6\u30a9\u30fc\u30eb\u306e\u8a2d\u5b9a\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n<h2>JupyterNotebook\u306e\u904b\u7528<\/h2>\n<h3>\u30c8\u30fc\u30af\u30f3\u306e\u524a\u9664<\/h3>\n<p>jupyter\u306b\u63a5\u7d9a\u3059\u308bURL\u306b\u542b\u307e\u308c\u308btoken=\u306e\u90e8\u5206\u306f\u3001jupyter\u3092\u8d77\u52d5\u3059\u308b\u305f\u3073\u306b\u5909\u66f4\u3055\u308c\u308b\u3002\u3082\u3057jupyter\u304c\u52d5\u4f5c\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u306b\u5916\u90e8\u304b\u3089\u63a5\u7d9a\u3067\u304d\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001token\u3092\u56fa\u5b9a\u3082\u3057\u304f\u306f\u524a\u9664\u3057\u3066\u52d5\u4f5c\u3055\u305b\u308b\u3068\u697d\u3067\u3059\u3002<br \/>\ntoken\u306e\u6307\u5b9a\u65b9\u6cd5\u306f3\u901a\u308a\u3042\u308a\u3001(1) jupyter_notebook_config.py\u306b\u8a2d\u5b9a\u3001(2) \u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u8a2d\u5b9a\u3001(3) jupyter\u306e\u8d77\u52d5\u6642\u30aa\u30d7\u30b7\u30e7\u30f3\u3068\u3057\u3066\u8a2d\u5b9a\u3001\u306e\u3044\u305a\u308c\u304b\u3067\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>(1)\u306e\u65b9\u6cd5\u306f\u30b3\u30f3\u30c6\u30ca\u3092\u524a\u9664\u3059\u308b\u3068\u5143\u306b\u623b\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3059\u3067\u306b\u30b3\u30f3\u30c6\u30ca\u3092\u4fee\u6b63\u3057\u3066\u3044\u3066\u3001\u524a\u9664\u3057\u305f\u304f\u306a\u3044\u3068\u304d\u306f\u3053\u306e\u65b9\u6cd5\u3092\u3068\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker exec -it mynote bash\n(base) jovyan@d4788834f9a1:~$ vi .jupyter\/jupyter_notebook_config.py\n(c.NotebookApp.token = \u3068\u3042\u308b\u884c\u3092\u4fee\u6b63\u3002\u5148\u982d\u306e#\u3092\u5916\u3059\u306e\u3092\u5fd8\u308c\u306a\u3044\u3088\u3046\u306b)\n(base) jovyan@d4788834f9a1:~$ exit\n# docker restart mynote\n<\/pre>\n<p>(2)\u306e\u65b9\u6cd5\u306fdocker run\u306e-e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker run -d --name mynote -p 10080:8888 -e JUPYTER_TOKEN=secret_token docker.io\/jupyter\/datascience-notebook<\/pre>\n<p>(3)\u306e\u65b9\u6cd5\u306fjupyter\u306e\u8d77\u52d5\u30b3\u30de\u30f3\u30c9\u306b\u5f15\u6570\u3092\u4e0e\u3048\u307e\u3059\u3002datascience-notebook\u306fstart-notebook.sh\u3092\u8d77\u52d5\u3059\u308b\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u3066\u3001\u3053\u308c\u306btoken\u3092\u5f15\u6570\u3068\u3057\u3066\u4e0e\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker run -d --name mynote -p 10080:8888 docker.io\/jupyter\/datascience-notebook start-notebook.sh --NotebookApp.token=''\n<\/pre>\n<p>(\u8d77\u52d5\u6642\u306b\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30de\u30f3\u30c9\u3092\u8abf\u3079\u308b\u306b\u306f docker inspect mynote \u3068\u3057\u3001\u51fa\u529b\u3055\u308c\u308bJSON\u304b\u3089Cmd\u306e\u5024\u3092\u63a2\u3057\u307e\u3059\u3002)<\/p>\n<h3>R\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8ffd\u52a0\u3057\u305f\u304f\u306a\u3063\u305f\u3089<\/h3>\n<p>\u30b3\u30f3\u30c6\u30ca\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u63a5\u7d9a\u3057\u307e\u3059\u3002\u305f\u3076\u3093root\u6a29\u9650\u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067-u\u3067\u30e6\u30fc\u30b6\u30fc\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"code\">docker exec -it -u root mynote bash\n(base) root@edfb3dfc0f44:~# R\n&gt; install.packages(\"BiocManager\", repos = \"https:\/\/cran.ism.ac.jp\/\")\n(\u9014\u4e2d\u7701\u7565)\n&gt; q()\nSave workspace image? [y\/n\/c]: n\n(base) root@edfb3dfc0f44:~# exit\n<\/pre>\n<h3>\u4f5c\u6210\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u3092\u4fdd\u5b58\u3057\u305f\u304f\u306a\u3063\u305f\u3089<\/h3>\n<p>\u30b3\u30f3\u30c6\u30ca\u3092export\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker export mynote &gt;mynote.tar<\/pre>\n<p>\u623b\u3059\u3068\u304d\u306fimport\u3067\u3059\u3002<\/p>\n<h3>\u4f5c\u6210\u3057\u305f\u30b3\u30f3\u30c6\u30ca\u3092\u4ed6\u306e\u5834\u6240\u3067\u3082\u4f7f\u3044\u305f\u304f\u306a\u3063\u305f\u3089<\/h3>\n<p>\u30b3\u30f3\u30c6\u30ca\u3092commit\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker commit mynote mynote_image<\/pre>\n<p>\u4f5c\u6210\u3055\u308c\u305fdocker\u30a4\u30e1\u30fc\u30b8(mynote_image)\u3092save\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker save mynote_image -i mynote_image<\/pre>\n<p>\u4f5c\u6210\u3055\u308c\u305fmynote_image\u3092\u4f7f\u3044\u305f\u3044\u5834\u6240\u3078\u3082\u3063\u3066\u3044\u3063\u3066\u3001load\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"code\"># docker load -i mynote_image<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u79c1\u306e3\u901a\u308a\u306eR\u306e\u4f7f\u3044\u65b9 Windows\u306eRGui \u826f\u3044\u3068\u3053\u308d \u30b0\u30e9\u30d5(\u753b\u50cf)\u304c\u305d\u306e\u5834\u3067\u8868\u793a\u3055\u308c\u308b\u3002 \u60aa\u3044\u3068\u3053\u308d \u30d8\u30eb\u30d7\u304c\u30d6\u30e9\u30a6\u30b6\u30fc\u3067\u8868\u793a\u3055\u308c\u308b(\u898b\u308b\u305f\u3073\u306b\u30bf\u30d6\u304c\u5897\u3048\u3066\u3044\u304f)\u3002Linux\u3067\u89e3\u6790\u3057\u305f\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u306e\u304c\u9762\u5012( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,16,13],"tags":[],"_links":{"self":[{"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/posts\/1381"}],"collection":[{"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/comments?post=1381"}],"version-history":[{"count":49,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/posts\/1381\/revisions"}],"predecessor-version":[{"id":1430,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/posts\/1381\/revisions\/1430"}],"wp:attachment":[{"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/media?parent=1381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/categories?post=1381"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/tags?post=1381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}