20210426のdockerに関する記事は20件です。

Docker runでsystemdを起動しつつスクリプトを動かす

はじめに Docker上でsystemdを使用したサービスを起動したいと思ったが調べるのに思いのほか苦戦してしまったのでここに残します ※systemdで起動しているものを直接起動してよいのならばsystemdを使用する必要はありません ※この記事ではprivilegedオプションを使用するため権限には十分注意してください systemdとは Linuxカーネルが起動する(PID 1)のinitプロセス。 このsystemdはすべてのプロセスの親となります Docker(centos7)上のsystemd Docker上では基本的にsystemdを有効にされていません。 systemdが起動していないとsystemctlコマンドを使って操作するサービスを使うことができません。 有効にするためにはprivilegedオプションで特権を許可、PID1で/sbin/initを実行する必要があります。 しかし、PID1で起動するためにはDocker run時に/sbin/initを実行しなければならないためユーザースクリプトを起動できません。 ユーザースクリプトを起動しその中で/sbin/initを実行してもPID1にならないためです。 サービスの自動実行 本来起動時に実行されるサービスは以下のようなコマンドで有効にします systemctl enable <サービス名> しかし、/sbin/init起動前には実行できず、/sbin/init起動後はユーザースクリプトを起動できません。 そのため、手動でsystemctl enableと同じ操作を行います。 準備 単純な自作サービスを作成し、自動実行することを目指します。 以下のサービス設定ファイルをmyService.serviceとして保存します [Unit] Description=自作のテストサービス [Service] Type=simple ExecStart=/test/startup.sh Restartno [Install] WantedBy=multi-user.target また、startup.shとして以下を保存します。 #! /bin/sh echo "hogehoge" 最後にDockerfileを作成します。 自動起動の手動設定としてシンボリックリンクをデフォルトの自動起動ユニット(multi-user.target)の依存関係に追加しています FROM centos:7 COPY myService.service /etc/systemd/system/myService.service RUN ln -s /etc/systemd/system/myService.service /etc/systemd/system/multi-user.target.wants/myService.service COPY startup.sh /test/startup.sh RUN chmod +x /test/startup.sh CMD ["/sbin/init"] 実行 docker build -t systemdtest . docker run -d --privileged --name systemdtest systemdtest 以下のコマンドで動作確認します docker exec systemdTest systemctl status myService 実行結果は以下のようになっており、実際に起動し、終了したことがわかります。 ● myService.service - 自作のテストサービス Loaded: loaded (/etc/systemd/system/myService.service; enabled; vendor preset: disabled) Active: inactive (dead) since Mon 2021-04-26 13:42:42 UTC; 14s ago Process: 53 ExecStart=/test/startup.sh (code=exited, status=0/SUCCESS) Main PID: 53 (code=exited, status=0/SUCCESS) Apr 26 13:42:42 4c44e9ad157e systemd[1]: Started 自作のテストサービス. Apr 26 13:42:42 4c44e9ad157e startup.sh[53]: hogehoge おわりに 誤った記述や誤字脱字など指摘あれば是非お願いします
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

「「Rによる機械学習」の勉強履歴(1)」後追い: dockerで機械学習(77) with R (7)

「Rによる機械学習」の勉強履歴(1) https://qiita.com/kazuo_reve/items/d45506146aeef52f6c65 の後追いをする。 まずdockerで作業場を作る。 今日のdocker error: RStudio (解決) https://qiita.com/kaizen_nagoya/items/e1a757874e1e3e2c9765 bash docker run --rm -p 8787:8787 -e PASSWORD=yourpasswordhere rocker/rstudio ブラウザを開いて、localhost:8787 でIDとpasswordの入力画面が出る。 IDはrstudio, ppasswordは、コマンドで指定したもの。 無事、ログインした。 R R version 4.0.5 (2021-03-31) -- "Shake and Throw" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. ログインしたら、ダウンロードしたい。 shellを走らせよう。 幸い、ログインの説明ページに、shell の走らせ方も載っていた。 やっぱRやってる人たちって、肝心なことがわかってるって感じ。 Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio 次に、別のコマンドから、 bash $ docker exec -ti 0990b19a57db bash ログインした先で、 bash # apt update; apt -y upgrade # wget https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition/archive/refs/heads/master.zip # unzip master.zip PacktPublishing/Machine-Learning-with-R-Third-Edition https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition 第二章のプログラムを動かそうとしたらエラーが出た。 「tools」メニューからgmodelsをinstallすると、コマンドに命令が現れた。 > install.packages("gmodels") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘gtools’, ‘gdata’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gtools_3.8.2.tar.gz' Content type 'binary/octet-stream' length 324517 bytes (316 KB) ================================================== downloaded 316 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gdata_2.18.0.tar.gz' Content type 'binary/octet-stream' length 1216305 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gmodels_2.18.1.tar.gz' Content type 'binary/octet-stream' length 111902 bytes (109 KB) ================================================== downloaded 109 KB * installing *binary* package ‘gtools’ ... * DONE (gtools) * installing *binary* package ‘gdata’ ... * DONE (gdata) * installing *binary* package ‘gmodels’ ... * DONE (gmodels) The downloaded source packages are in ‘/tmp/RtmpX7KsLR/downloaded_packages’ 「run」を押した。 bash > # create vectors of data for three medical patients > subject_name <- c("John Doe", "Jane Doe", "Steve Graves") 続きをしたいのでdocker hubに登録 bash $ $ docker commit 0990b19a57db kaizenjapan/rstudio $ docker push kaizenjapan/rstudio The push refers to repository [docker.io/kaizenjapan/rstudio] 955d73ad8db0: Pushed 975f6564f91e: Mounted from rocker/rstudio 904f4d5a6efd: Mounted from rocker/rstudio 8e5e03028587: Mounted from rocker/rstudio 9fbdaeca625e: Pushed 346be19f13b0: Mounted from rocker/rstudio 935f303ebf75: Mounted from rocker/rstudio 0e64bafdc7ee: Mounted from rocker/rstudio latest: digest: sha256:751a292c52041f6643ec3328d84fc512a2ce6635128ac476c4546e07ab206176 size: 2000 第5章 R > ## Understanding Decision Trees ---- > # calculate entropy of a two-class segment > -0.60 * log2(0.60) - 0.40 * log2(0.40) [1] 0.9709506 directory一覧 Machine-Learning-with-R-Cookbook-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook Machine-Learning-with-R-Cookbook-Second-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook-Second-Edition Machine-Learning-with-R-Quick-Start-Guide-master https://github.com/PacktPublishing/Machine-Learning-with-R-Quick-Start-Guide Machine-Learning-with-R-Second-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Second-Edition Machine-Learning-with-R-Third-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition 4th editionは入れ物だけ存在。 参考資料(reference) dockerで機械学習(76) with R (6)「Mastering Machine Learning with R 」By Cory Lesmeister https://qiita.com/kaizen_nagoya/items/c3d51cdd3b811dac4d26 Rstudio入門 https://qiita.com/kaizen_nagoya/items/4f8bc5dd48cbc8d50329
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

「Rによる機械学習」の勉強履歴(1)の後追い

「Rによる機械学習」の勉強履歴(1) https://qiita.com/kazuo_reve/items/d45506146aeef52f6c65 の後追いをする。 まずdockerで作業場を作る。 今日のdocker error: RStudio (解決) https://qiita.com/kaizen_nagoya/items/e1a757874e1e3e2c9765 ログインしたら、ダウンロードしたいので、shellを走らせる。 幸い、ログインの説明ページに、shell の走らせ方も載っていた。 やっぱRやってる人たちって、肝心なことがわかってるって感じ。 Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio bash $ docker exec -ti 0990b19a57db bash ログインした先で、 bash # apt update; apt -y upgrade # wget https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition/archive/refs/heads/master.zip # unzip master.zip PacktPublishing/Machine-Learning-with-R-Third-Edition https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition 第二章のプログラムを動かそうとしたらエラーが出た。 toolメニューからgmodelsをinstallすると、コマンドに命令が現れた。 > install.packages("gmodels") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘gtools’, ‘gdata’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gtools_3.8.2.tar.gz' Content type 'binary/octet-stream' length 324517 bytes (316 KB) ================================================== downloaded 316 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gdata_2.18.0.tar.gz' Content type 'binary/octet-stream' length 1216305 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gmodels_2.18.1.tar.gz' Content type 'binary/octet-stream' length 111902 bytes (109 KB) ================================================== downloaded 109 KB * installing *binary* package ‘gtools’ ... * DONE (gtools) * installing *binary* package ‘gdata’ ... * DONE (gdata) * installing *binary* package ‘gmodels’ ... * DONE (gmodels) The downloaded source packages are in ‘/tmp/RtmpX7KsLR/downloaded_packages’ runを押した。 bash > # create vectors of data for three medical patients > subject_name <- c("John Doe", "Jane Doe", "Steve Graves") 参考資料(reference) dockerで機械学習(76) with R (6)「Mastering Machine Learning with R 」By Cory Lesmeister https://qiita.com/kaizen_nagoya/items/c3d51cdd3b811dac4d26 Rstudio入門 https://qiita.com/kaizen_nagoya/items/4f8bc5dd48cbc8d50329
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

「「Rによる機械学習」の勉強履歴(1)」後追い

「Rによる機械学習」の勉強履歴(1) https://qiita.com/kazuo_reve/items/d45506146aeef52f6c65 の後追いをする。 まずdockerで作業場を作る。 今日のdocker error: RStudio (解決) https://qiita.com/kaizen_nagoya/items/e1a757874e1e3e2c9765 bash docker run --rm -p 8787:8787 -e PASSWORD=yourpasswordhere rocker/rstudio ブラウザを開いて、localhost:8787 でIDとpasswordの入力画面が出る。 IDはrstudio, ppasswordは、コマンドで指定したもの。 無事、ログインした。 R R version 4.0.5 (2021-03-31) -- "Shake and Throw" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. ログインしたら、ダウンロードしたい。 shellを走らせよう。 幸い、ログインの説明ページに、shell の走らせ方も載っていた。 やっぱRやってる人たちって、肝心なことがわかってるって感じ。 Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio 次に、別のコマンドから、 bash $ docker exec -ti 0990b19a57db bash ログインした先で、 bash # apt update; apt -y upgrade # wget https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition/archive/refs/heads/master.zip # unzip master.zip PacktPublishing/Machine-Learning-with-R-Third-Edition https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition 第二章のプログラムを動かそうとしたらエラーが出た。 「tools」メニューからgmodelsをinstallすると、コマンドに命令が現れた。 > install.packages("gmodels") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘gtools’, ‘gdata’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gtools_3.8.2.tar.gz' Content type 'binary/octet-stream' length 324517 bytes (316 KB) ================================================== downloaded 316 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gdata_2.18.0.tar.gz' Content type 'binary/octet-stream' length 1216305 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gmodels_2.18.1.tar.gz' Content type 'binary/octet-stream' length 111902 bytes (109 KB) ================================================== downloaded 109 KB * installing *binary* package ‘gtools’ ... * DONE (gtools) * installing *binary* package ‘gdata’ ... * DONE (gdata) * installing *binary* package ‘gmodels’ ... * DONE (gmodels) The downloaded source packages are in ‘/tmp/RtmpX7KsLR/downloaded_packages’ 「run」を押した。 bash > # create vectors of data for three medical patients > subject_name <- c("John Doe", "Jane Doe", "Steve Graves") 続きをしたいのでdocker hubに登録 bash $ $ docker commit 0990b19a57db kaizenjapan/rstudio $ docker push kaizenjapan/rstudio The push refers to repository [docker.io/kaizenjapan/rstudio] 955d73ad8db0: Pushed 975f6564f91e: Mounted from rocker/rstudio 904f4d5a6efd: Mounted from rocker/rstudio 8e5e03028587: Mounted from rocker/rstudio 9fbdaeca625e: Pushed 346be19f13b0: Mounted from rocker/rstudio 935f303ebf75: Mounted from rocker/rstudio 0e64bafdc7ee: Mounted from rocker/rstudio latest: digest: sha256:751a292c52041f6643ec3328d84fc512a2ce6635128ac476c4546e07ab206176 size: 2000 第5章 R > ## Understanding Decision Trees ---- > # calculate entropy of a two-class segment > -0.60 * log2(0.60) - 0.40 * log2(0.40) [1] 0.9709506 directory一覧 Machine-Learning-with-R-Cookbook-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook Machine-Learning-with-R-Cookbook-Second-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook-Second-Edition Machine-Learning-with-R-Quick-Start-Guide-master https://github.com/PacktPublishing/Machine-Learning-with-R-Quick-Start-Guide Machine-Learning-with-R-Second-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Second-Edition Machine-Learning-with-R-Third-Edition-master https://github.com/PacktPublishing/Machine-Learning-with-R-Third-Edition 4th editionは入れ物だけ存在。 参考資料(reference) dockerで機械学習(76) with R (6)「Mastering Machine Learning with R 」By Cory Lesmeister https://qiita.com/kaizen_nagoya/items/c3d51cdd3b811dac4d26 Rstudio入門 https://qiita.com/kaizen_nagoya/items/4f8bc5dd48cbc8d50329
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

今日のdocker error: RStudio (解決)->ファイルエラー等

今日のdocker error Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio ついつい、書いてあることと違うことをした。 bash $ docker run --rm -p 8787:8787 rocker/rstudio -it /bin/bash Unable to find image 'rocker/rstudio:latest' locally latest: Pulling from rocker/rstudio a70d879fa598: Pull complete c4394a92d1f8: Pull complete 10e6159c56c0: Pull complete 833bebb909e4: Pull complete 9bceb8b50184: Pull complete e925a327b30d: Pull complete 01c3425e0ade: Pull complete Digest: sha256:109863d20ff03446fa87aad09004d307c2795d8f62054f34805aa16a0a25518d Status: Downloaded newer image for rocker/rstudio:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-it\": executable file not found in $PATH": unknown. みごとにエラッた。 bash $ docker run --rm -p 8787:8787 rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... ERROR: You must set a unique PASSWORD (not 'rstudio') first! e.g. run with: docker run -e PASSWORD=<YOUR_PASS> -p 8787:8787 rocker/rstudio [cont-init.d] userconf: exited 1. [cont-init.d] done. [services.d] starting services [services.d] done. ^C [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting. パスワード省略してもいいって書いてなかったっけ。 $ docker run --rm -p 8787:8787 -e PASSWORD=password rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... [cont-init.d] userconf: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. 26 Apr 2021 12:16:28 [rserver] ERROR system error 2 (No such file or directory) [description: User not found., user-value: user-value]; OCCURRED AT rstudio::core::Error rstudio::core::system::User::Impl::populateUser(rstudio::core::system::User::Impl::GetPasswdFunc<T>&, T) [with T = const char* rstudio::core::system::User::Impl::GetPasswdFunc<T> = std::function<int(const char*, passwd*, char*, long unsigned int, passwd**)>] src/cpp/shared_core/system/User.cpp:68; LOGGED FROM: std::__cxx11::string rstudio::server::pam_auth::{anonymous}::userIdentifierToLocalUsername(const string&) src/cpp/server/ServerPAMAuth.cpp:96 Docker でユーザ名を指定してコンテナを起動する https://qiita.com/syoyo/items/6fa6597b7a6625000e33 bash $ docker run --rm -p 8787:8787 -u kiyoshi -e PASSWORD=password rocker/rstudio docker: Error response from daemon: unable to find user kiyoshi: no matching entries in passwd file. Visit localhost:8787 in your browser and log in with username rstudio and the password you set. NB: Setting a password is now REQUIRED. Container will error otherwise. あ、userはrstudioだって書いてあった。 入れた。ありがと。 ファイルエラー 「「Rによる機械学習」の勉強履歴(1)」後追い https://qiita.com/kaizen_nagoya/items/68170a86b1b3dd5e596b 第3章のファイルを読み込んで Runしたら Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'wisc_bc_data.csv': No such file or directory ファイルはあるのに。 R ScriptやR Markdownからinstall.packages()を呼び出す場合はレポジトリを指定しないとエラーになる https://qiita.com/maech/items/03b9566fb0fe940e1736 第4章でも、 > # read the sms data into the sms data frame > sms_raw <- read.csv("sms_spam.csv", stringsAsFactors = FALSE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'sms_spam.csv': No such file or directory library 第4章のライブラリは大きかった。無事導入。 ** Installing R Packages: 'e1071', 'SnowballC', 'tm', 'wordcloud' [1/11] Installing proxy... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/proxy_0.4-25.tar.gz' Content type 'binary/octet-stream' length 251003 bytes (245 KB) ================================================== downloaded 245 KB [2/11] Installing e1071... * installing *binary* package ‘proxy’ ... * DONE (proxy) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/e1071_1.7-6.tar.gz' Content type 'binary/octet-stream' length 919381 bytes (897 KB) ================================================== downloaded 897 KB [3/11] Installing SnowballC... * installing *binary* package ‘e1071’ ... * DONE (e1071) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SnowballC_0.7.0.tar.gz' Content type 'binary/octet-stream' length 631384 bytes (616 KB) ================================================== downloaded 616 KB * installing *binary* package ‘SnowballC’ ... * DONE (SnowballC) [4/11] Installing NLP... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/NLP_0.2-1.tar.gz' Content type 'binary/octet-stream' length 384436 bytes (375 KB) ================================================== downloaded 375 KB * installing *binary* package ‘NLP’ ... * DONE (NLP) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ [5/11] Installing Rcpp... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Rcpp_1.0.6.tar.gz' Content type 'binary/octet-stream' length 4150785 bytes (4.0 MB) ================================================== downloaded 4.0 MB * installing *binary* package ‘Rcpp’ ... * DONE (Rcpp) [6/11] Installing slam... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/slam_0.1-48.tar.gz' Content type 'binary/octet-stream' length 221661 bytes (216 KB) ================================================== downloaded 216 KB [7/11] Installing xml2... * installing *binary* package ‘slam’ ... * DONE (slam) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xml2_1.3.2.tar.gz' Content type 'binary/octet-stream' length 616796 bytes (602 KB) ================================================== downloaded 602 KB * installing *binary* package ‘xml2’ ... * DONE (xml2) [8/11] Installing BH... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/BH_1.75.0-0.tar.gz' Content type 'binary/octet-stream' length 11877438 bytes (11.3 MB) ================================================== downloaded 11.3 MB * installing *binary* package ‘BH’ ... * DONE (BH) [9/11] Installing tm... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tm_0.7-8.tar.gz' Content type 'binary/octet-stream' length 1440316 bytes (1.4 MB) ================================================== downloaded 1.4 MB [10/11] Installing RColorBrewer... * installing *binary* package ‘tm’ ... * DONE (tm) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RColorBrewer_1.1-2.tar.gz' Content type 'binary/octet-stream' length 52761 bytes (51 KB) ================================================== downloaded 51 KB * installing *binary* package ‘RColorBrewer’ ... * DONE (RColorBrewer) [11/11] Installing wordcloud... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/wordcloud_2.6.tar.gz' Content type 'binary/octet-stream' length 448713 bytes (438 KB) ================================================== downloaded 438 KB * installing *binary* package ‘wordcloud’ ... * DONE (wordcloud) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ ✔ Packages successfully installed. 第5章 ** Installing R Packages: 'C50', 'OneR', 'RWeka' [1/7] Installing partykit... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘libcoin’, ‘mvtnorm’, ‘Formula’, ‘inum’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/libcoin_1.0-8.tar.gz' Content type 'binary/octet-stream' length 1052493 bytes (1.0 MB) ================================================== downloaded 1.0 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/mvtnorm_1.1-1.tar.gz' Content type 'binary/octet-stream' length 262905 bytes (256 KB) ================================================== downloaded 256 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Formula_1.2-4.tar.gz' Content type 'binary/octet-stream' length 175098 bytes (170 KB) ================================================== downloaded 170 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/inum_1.0-4.tar.gz' Content type 'binary/octet-stream' length 36473 bytes (35 KB) ================================================== downloaded 35 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/partykit_1.2-13.tar.gz' Content type 'binary/octet-stream' length 2425357 bytes (2.3 MB) ================================================== downloaded 2.3 MB * installing *binary* package ‘mvtnorm’ ... * DONE (mvtnorm) * installing *binary* package ‘Formula’ ... * DONE (Formula) * installing *binary* package ‘libcoin’ ... * DONE (libcoin) * installing *binary* package ‘inum’ ... * DONE (inum) [2/7] Installing Cubist... * installing *binary* package ‘partykit’ ... * DONE (partykit) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘glue’, ‘magrittr’, ‘stringi’, ‘plyr’, ‘stringr’, ‘reshape2’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/glue_1.4.2.tar.gz' Content type 'binary/octet-stream' length 144331 bytes (140 KB) ================================================== downloaded 140 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/magrittr_2.0.1.tar.gz' Content type 'binary/octet-stream' length 232440 bytes (226 KB) ================================================== downloaded 226 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/stringi_1.5.3.tar.gz' Content type 'binary/octet-stream' length 2902983 bytes (2.8 MB) ================================================== downloaded 2.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/plyr_1.8.6.tar.gz' Content type 'binary/octet-stream' length 1153520 bytes (1.1 MB) ================================================== downloaded 1.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/stringr_1.4.0.tar.gz' Content type 'binary/octet-stream' length 204624 bytes (199 KB) ================================================== downloaded 199 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/reshape2_1.4.4.tar.gz' Content type 'binary/octet-stream' length 537015 bytes (524 KB) ================================================== downloaded 524 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Cubist_0.2.3.tar.gz' Content type 'binary/octet-stream' length 649064 bytes (633 KB) ================================================== downloaded 633 KB * installing *binary* package ‘glue’ ... * DONE (glue) * installing *binary* package ‘magrittr’ ... * DONE (magrittr) * installing *binary* package ‘stringi’ ... * DONE (stringi) * installing *binary* package ‘plyr’ ... * DONE (plyr) * installing *binary* package ‘stringr’ ... * DONE (stringr) * installing *binary* package ‘reshape2’ ... * DONE (reshape2) [3/7] Installing C50... * installing *binary* package ‘Cubist’ ... * DONE (Cubist) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/C50_0.1.3.1.tar.gz' Content type 'binary/octet-stream' length 604693 bytes (590 KB) ================================================== downloaded 590 KB * installing *binary* package ‘C50’ ... * DONE (C50) [4/7] Installing OneR... The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/OneR_2.2.tar.gz' Content type 'binary/octet-stream' length 106149 bytes (103 KB) ================================================== downloaded 103 KB [5/7] Installing RWekajars... * installing *binary* package ‘OneR’ ... * DONE (OneR) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘rJava’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rJava_0.9-13.tar.gz' Content type 'binary/octet-stream' length 933124 bytes (911 KB) ================================================== downloaded 911 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RWekajars_3.9.3-2.tar.gz' Content type 'binary/octet-stream' length 10028473 bytes (9.6 MB) ================================================== downloaded 9.6 MB * installing *binary* package ‘rJava’ ... * DONE (rJava) [6/7] Installing rJava... * installing *binary* package ‘RWekajars’ ... * DONE (RWekajars) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rJava_0.9-13.tar.gz' Content type 'binary/octet-stream' length 933124 bytes (911 KB) ================================================== downloaded 911 KB * installing *binary* package ‘rJava’ ... [7/7] Installing RWeka... * DONE (rJava) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RWeka_0.4-43.tar.gz' Content type 'binary/octet-stream' length 626084 bytes (611 KB) ================================================== downloaded 611 KB * installing *binary* package ‘RWeka’ ... * DONE (RWeka) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ ✔ Packages successfully installed. 第6章 ** Installing R Packages: 'psych', 'rpart.plot' [1/3] Installing mnormt... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘tmvnsim’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tmvnsim_1.0-2.tar.gz' Content type 'binary/octet-stream' length 25085 bytes (24 KB) ================================================== downloaded 24 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/mnormt_2.0.2.tar.gz' Content type 'binary/octet-stream' length 187894 bytes (183 KB) ================================================== downloaded 183 KB * installing *binary* package ‘tmvnsim’ ... * DONE (tmvnsim) [2/3] Installing psych... * installing *binary* package ‘mnormt’ ... * DONE (mnormt) The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/psych_2.1.3.tar.gz' Content type 'binary/octet-stream' length 4093812 bytes (3.9 MB) ================================================== downloaded 3.9 MB * installing *binary* package ‘psych’ ... * DONE (psych) [3/3] Installing rpart.plot... The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rpart.plot_3.0.9.tar.gz' Content type 'binary/octet-stream' length 1012900 bytes (989 KB) ================================================== downloaded 989 KB * installing *binary* package ‘rpart.plot’ ... * DONE (rpart.plot) The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ ✔ Packages successfully installed. 実行はエラー:ファイルあるのに。 > ## Understanding regression ---- > ## Example: Space Shuttle Launch Data ---- > launch <- read.csv("challenger.csv") Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'challenger.csv': No such file or directory 第7章 ** Installing R Packages: 'kernlab', 'neuralnet' [1/3] Installing kernlab... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/kernlab_0.9-29.tar.gz' Content type 'binary/octet-stream' length 2525692 bytes (2.4 MB) ================================================== downloaded 2.4 MB * installing *binary* package ‘kernlab’ ... * DONE (kernlab) [2/3] Installing Deriv... The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Deriv_4.1.3.tar.gz' Content type 'binary/octet-stream' length 146530 bytes (143 KB) ================================================== downloaded 143 KB [3/3] Installing neuralnet... * installing *binary* package ‘Deriv’ ... * DONE (Deriv) The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/neuralnet_1.44.2.tar.gz' Content type 'binary/octet-stream' length 121398 bytes (118 KB) ================================================== downloaded 118 KB * installing *binary* package ‘neuralnet’ ... * DONE (neuralnet) The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ ✔ Packages successfully installed. これもエラー > ## Step 2: Exploring and preparing the data ---- > # read in data and examine structure > concrete <- read.csv("concrete.csv") Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'concrete.csv': No such file or directory 第8章 Installing 'arules' ... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/arules_1.6-7.tar.gz' Content type 'binary/octet-stream' length 2650723 bytes (2.5 MB) ================================================== downloaded 2.5 MB * installing *binary* package ‘arules’ ... * DONE (arules) The downloaded source packages are in ‘/tmp/RtmpPlEr9q/downloaded_packages’ ✔ Package 'arules' successfully installed. で、 > groceries <- read.transactions("groceries.csv", sep = ",") Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'groceries.csv': No such file or directory 第9章 追加はない。エラーはある。 > ## Example: Finding Teen Market Segments ---- > ## Step 2: Exploring and preparing the data ---- > teens <- read.csv("snsdata.csv", stringsAsFactors = TRUE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'snsdata.csv': No such file or directory 第10章 ** Installing R Packages: 'caret', 'irr', 'pROC', 'vcd' [1/12] Installing ggplot2... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘colorspace’, ‘cli’, ‘crayon’, ‘utf8’, ‘farver’, ‘labeling’, ‘lifecycle’, ‘munsell’, ‘R6’, ‘viridisLite’, ‘ellipsis’, ‘fansi’, ‘pillar’, ‘pkgconfig’, ‘vctrs’, ‘digest’, ‘gtable’, ‘isoband’, ‘rlang’, ‘scales’, ‘tibble’, ‘withr’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/colorspace_2.0-0.tar.gz' Content type 'binary/octet-stream' length 2618313 bytes (2.5 MB) ================================================== downloaded 2.5 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cli_2.4.0.tar.gz' Content type 'binary/octet-stream' length 488804 bytes (477 KB) ================================================== downloaded 477 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/crayon_1.4.1.tar.gz' Content type 'binary/octet-stream' length 138304 bytes (135 KB) ================================================== downloaded 135 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/utf8_1.2.1.tar.gz' Content type 'binary/octet-stream' length 237032 bytes (231 KB) ================================================== downloaded 231 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/farver_2.1.0.tar.gz' Content type 'binary/octet-stream' length 2605228 bytes (2.5 MB) ================================================== downloaded 2.5 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/labeling_0.4.2.tar.gz' Content type 'binary/octet-stream' length 58749 bytes (57 KB) ================================================== downloaded 57 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lifecycle_1.0.0.tar.gz' Content type 'binary/octet-stream' length 93210 bytes (91 KB) ================================================== downloaded 91 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/munsell_0.5.0.tar.gz' Content type 'binary/octet-stream' length 240635 bytes (234 KB) ================================================== downloaded 234 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/R6_2.5.0.tar.gz' Content type 'binary/octet-stream' length 82062 bytes (80 KB) ================================================== downloaded 80 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/viridisLite_0.4.0.tar.gz' Content type 'binary/octet-stream' length 1295982 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ellipsis_0.3.1.tar.gz' Content type 'binary/octet-stream' length 37504 bytes (36 KB) ================================================== downloaded 36 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/fansi_0.4.2.tar.gz' Content type 'binary/octet-stream' length 253817 bytes (247 KB) ================================================== downloaded 247 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pillar_1.6.0.tar.gz' Content type 'binary/octet-stream' length 1004228 bytes (980 KB) ================================================== downloaded 980 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pkgconfig_2.0.3.tar.gz' Content type 'binary/octet-stream' length 17398 bytes (16 KB) ================================================== downloaded 16 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/vctrs_0.3.7.tar.gz' Content type 'binary/octet-stream' length 1606882 bytes (1.5 MB) ================================================== downloaded 1.5 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/digest_0.6.27.tar.gz' Content type 'binary/octet-stream' length 357339 bytes (348 KB) ================================================== downloaded 348 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gtable_0.3.0.tar.gz' Content type 'binary/octet-stream' length 430032 bytes (419 KB) ================================================== downloaded 419 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/isoband_0.2.4.tar.gz' Content type 'binary/octet-stream' length 4607656 bytes (4.4 MB) ================================================== downloaded 4.4 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rlang_0.4.10.tar.gz' Content type 'binary/octet-stream' length 1394159 bytes (1.3 MB) ================================================== downloaded 1.3 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/scales_1.1.1.tar.gz' Content type 'binary/octet-stream' length 545321 bytes (532 KB) ================================================== downloaded 532 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tibble_3.1.1.tar.gz' Content type 'binary/octet-stream' length 810888 bytes (791 KB) ================================================== downloaded 791 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/withr_2.4.2.tar.gz' Content type 'binary/octet-stream' length 205998 bytes (201 KB) ================================================== downloaded 201 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ggplot2_3.3.3.tar.gz' Content type 'binary/octet-stream' length 4058120 bytes (3.9 MB) ================================================== downloaded 3.9 MB * installing *binary* package ‘colorspace’ ... * DONE (colorspace) * installing *binary* package ‘cli’ ... * DONE (cli) * installing *binary* package ‘crayon’ ... * DONE (crayon) * installing *binary* package ‘utf8’ ... * DONE (utf8) * installing *binary* package ‘farver’ ... * DONE (farver) * installing *binary* package ‘labeling’ ... * DONE (labeling) * installing *binary* package ‘R6’ ... * DONE (R6) * installing *binary* package ‘viridisLite’ ... * DONE (viridisLite) * installing *binary* package ‘fansi’ ... * DONE (fansi) * installing *binary* package ‘pkgconfig’ ... * DONE (pkgconfig) * installing *binary* package ‘digest’ ... * DONE (digest) * installing *binary* package ‘gtable’ ... * DONE (gtable) * installing *binary* package ‘isoband’ ... * DONE (isoband) * installing *binary* package ‘rlang’ ... * DONE (rlang) * installing *binary* package ‘withr’ ... * DONE (withr) * installing *binary* package ‘lifecycle’ ... * DONE (lifecycle) * installing *binary* package ‘munsell’ ... * DONE (munsell) * installing *binary* package ‘ellipsis’ ... * DONE (ellipsis) * installing *binary* package ‘vctrs’ ... * DONE (vctrs) * installing *binary* package ‘scales’ ... * DONE (scales) * installing *binary* package ‘pillar’ ... * DONE (pillar) * installing *binary* package ‘tibble’ ... * DONE (tibble) * installing *binary* package ‘ggplot2’ ... * DONE (ggplot2) [2/12] Installing foreach... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘iterators’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/iterators_1.0.13.tar.gz' Content type 'binary/octet-stream' length 335079 bytes (327 KB) ================================================== downloaded 327 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/foreach_1.5.1.tar.gz' Content type 'binary/octet-stream' length 134469 bytes (131 KB) ================================================== downloaded 131 KB * installing *binary* package ‘iterators’ ... * DONE (iterators) * installing *binary* package ‘foreach’ ... * DONE (foreach) [3/12] Installing ModelMetrics... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘data.table’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/data.table_1.14.0.tar.gz' Content type 'binary/octet-stream' length 2620758 bytes (2.5 MB) ================================================== downloaded 2.5 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ModelMetrics_1.2.2.2.tar.gz' Content type 'binary/octet-stream' length 1132424 bytes (1.1 MB) ================================================== downloaded 1.1 MB * installing *binary* package ‘data.table’ ... * DONE (data.table) [4/12] Installing recipes... * installing *binary* package ‘ModelMetrics’ ... * DONE (ModelMetrics) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘numDeriv’, ‘SQUAREM’, ‘lava’, ‘prodlim’, ‘cpp11’, ‘dplyr’, ‘generics’, ‘gower’, ‘ipred’, ‘lubridate’, ‘purrr’, ‘tidyr’, ‘tidyselect’, ‘timeDate’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/numDeriv_2016.8-1.1.tar.gz' Content type 'binary/octet-stream' length 112771 bytes (110 KB) ================================================== downloaded 110 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SQUAREM_2021.1.tar.gz' Content type 'binary/octet-stream' length 177255 bytes (173 KB) ================================================== downloaded 173 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lava_1.6.9.tar.gz' Content type 'binary/octet-stream' length 2714777 bytes (2.6 MB) ================================================== downloaded 2.6 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/prodlim_2019.11.13.tar.gz' Content type 'binary/octet-stream' length 421010 bytes (411 KB) ================================================== downloaded 411 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cpp11_0.2.7.tar.gz' Content type 'binary/octet-stream' length 195740 bytes (191 KB) ================================================== downloaded 191 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/dplyr_1.0.5.tar.gz' Content type 'binary/octet-stream' length 1244253 bytes (1.2 MB) ================================================== downloaded 1.2 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/generics_0.1.0.tar.gz' Content type 'binary/octet-stream' length 66014 bytes (64 KB) ================================================== downloaded 64 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gower_0.2.2.tar.gz' Content type 'binary/octet-stream' length 178401 bytes (174 KB) ================================================== downloaded 174 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ipred_0.9-11.tar.gz' Content type 'binary/octet-stream' length 387892 bytes (378 KB) ================================================== downloaded 378 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lubridate_1.7.10.tar.gz' Content type 'binary/octet-stream' length 1997569 bytes (1.9 MB) ================================================== downloaded 1.9 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/purrr_0.3.4.tar.gz' Content type 'binary/octet-stream' length 426832 bytes (416 KB) ================================================== downloaded 416 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tidyr_1.1.3.tar.gz' Content type 'binary/octet-stream' length 1086024 bytes (1.0 MB) ================================================== downloaded 1.0 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tidyselect_1.1.0.tar.gz' Content type 'binary/octet-stream' length 197666 bytes (193 KB) ================================================== downloaded 193 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/timeDate_3043.102.tar.gz' Content type 'binary/octet-stream' length 1544895 bytes (1.5 MB) ================================================== downloaded 1.5 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/recipes_0.1.16.tar.gz' Content type 'binary/octet-stream' length 1188900 bytes (1.1 MB) ================================================== downloaded 1.1 MB * installing *binary* package ‘numDeriv’ ... * DONE (numDeriv) * installing *binary* package ‘SQUAREM’ ... * DONE (SQUAREM) * installing *binary* package ‘cpp11’ ... * DONE (cpp11) * installing *binary* package ‘generics’ ... * DONE (generics) * installing *binary* package ‘gower’ ... * DONE (gower) * installing *binary* package ‘purrr’ ... * DONE (purrr) * installing *binary* package ‘timeDate’ ... * DONE (timeDate) * installing *binary* package ‘lava’ ... * DONE (lava) * installing *binary* package ‘lubridate’ ... * DONE (lubridate) * installing *binary* package ‘tidyselect’ ... * DONE (tidyselect) * installing *binary* package ‘prodlim’ ... * DONE (prodlim) * installing *binary* package ‘dplyr’ ... * DONE (dplyr) * installing *binary* package ‘ipred’ ... * DONE (ipred) * installing *binary* package ‘tidyr’ ... * DONE (tidyr) * installing *binary* package ‘recipes’ ... * DONE (recipes) [5/12] Installing withr... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/withr_2.4.2.tar.gz' Content type 'binary/octet-stream' length 205998 bytes (201 KB) ================================================== downloaded 201 KB * installing *binary* package ‘withr’ ... [6/12] Installing pROC... * DONE (withr) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pROC_1.17.0.1.tar.gz' Content type 'binary/octet-stream' length 1500903 bytes (1.4 MB) ================================================== downloaded 1.4 MB * installing *binary* package ‘pROC’ ... * DONE (pROC) [7/12] Installing caret... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caret_6.0-86.tar.gz' Content type 'binary/octet-stream' length 6243866 bytes (6.0 MB) ================================================== downloaded 6.0 MB [8/12] Installing lpSolve... * installing *binary* package ‘caret’ ... * DONE (caret) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lpSolve_5.6.15.tar.gz' Content type 'binary/octet-stream' length 1234173 bytes (1.2 MB) ================================================== downloaded 1.2 MB * installing *binary* package ‘lpSolve’ ... [9/12] Installing irr... * DONE (lpSolve) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/irr_0.84.1.tar.gz' Content type 'binary/octet-stream' length 147720 bytes (144 KB) ================================================== downloaded 144 KB * installing *binary* package ‘irr’ ... * DONE (irr) [10/12] Installing colorspace... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/colorspace_2.0-0.tar.gz' Content type 'binary/octet-stream' length 2618313 bytes (2.5 MB) ================================================== downloaded 2.5 MB * installing *binary* package ‘colorspace’ ... * DONE (colorspace) [11/12] Installing lmtest... The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘zoo’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/zoo_1.8-9.tar.gz' Content type 'binary/octet-stream' length 1032412 bytes (1008 KB) ================================================== downloaded 1008 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lmtest_0.9-38.tar.gz' Content type 'binary/octet-stream' length 398610 bytes (389 KB) ================================================== downloaded 389 KB * installing *binary* package ‘zoo’ ... * DONE (zoo) [12/12] Installing vcd... * installing *binary* package ‘lmtest’ ... * DONE (lmtest) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/vcd_1.4-8.tar.gz' Content type 'binary/octet-stream' length 1510183 bytes (1.4 MB) ================================================== downloaded 1.4 MB * installing *binary* package ‘vcd’ ... * DONE (vcd) The downloaded source packages are in ‘/tmp/RtmpYnfJZ5/downloaded_packages’ ✔ Packages successfully installed. 実行 > # obtain the predicted probabilities > sms_test_prob <- predict(sms_classifier, sms_test, type = "raw") Error in h(simpleError(msg, call)) : error in evaluating the argument 'object' in selecting a method for function 'predict': object 'sms_classifier' not found > え、オブジェクトがないってどゆこと。 第11章 ** Installing R Packages: 'adabag', 'randomForest' [1/3] Installing doParallel... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/doParallel_1.0.16.tar.gz' Content type 'binary/octet-stream' length 59742 bytes (58 KB) ================================================== downloaded 58 KB [2/3] Installing adabag... * installing *binary* package ‘doParallel’ ... * DONE (doParallel) The downloaded source packages are in ‘/tmp/RtmpEyKtH7/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/adabag_4.2.tar.gz' Content type 'binary/octet-stream' length 119400 bytes (116 KB) ================================================== downloaded 116 KB [3/3] Installing randomForest... * installing *binary* package ‘adabag’ ... * DONE (adabag) The downloaded source packages are in ‘/tmp/RtmpEyKtH7/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/randomForest_4.6-14.tar.gz' Content type 'binary/octet-stream' length 257439 bytes (251 KB) ================================================== downloaded 251 KB * installing *binary* package ‘randomForest’ ... * DONE (randomForest) The downloaded source packages are in ‘/tmp/RtmpEyKtH7/downloaded_packages’ ✔ Packages successfully installed. run > # load the credit dataset > credit <- read.csv("credit.csv", stringsAsFactors = TRUE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'credit.csv': No such file or directory 第12章 ** Installing R Packages: 'DBI', 'ff', 'ffbase', 'h2o', 'httr', 'igraph', 'jsonlite', 'odbc', 'ranger', 'RCurl', 'readr', 'rio', 'RODBC', 'RSQLite', 'rvest', 'sparklyr', 'XML' [1/45] Installing DBI... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/DBI_1.1.1.tar.gz' Content type 'binary/octet-stream' length 666548 bytes (650 KB) ================================================== downloaded 650 KB [2/45] Installing bit... * installing *binary* package ‘DBI’ ... * DONE (DBI) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/bit_4.0.4.tar.gz' Content type 'binary/octet-stream' length 688768 bytes (672 KB) ================================================== downloaded 672 KB [3/45] Installing ff... * installing *binary* package ‘bit’ ... * DONE (bit) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ff_4.0.4.tar.gz' Content type 'binary/octet-stream' length 1605260 bytes (1.5 MB) ================================================== downloaded 1.5 MB * installing *binary* package ‘ff’ ... * DONE (ff) [4/45] Installing fastmatch... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/fastmatch_1.1-0.tar.gz' Content type 'binary/octet-stream' length 60367 bytes (58 KB) ================================================== downloaded 58 KB [5/45] Installing ffbase... * installing *binary* package ‘fastmatch’ ... * DONE (fastmatch) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ffbase_0.13.3.tar.gz' Content type 'binary/octet-stream' length 367311 bytes (358 KB) ================================================== downloaded 358 KB * installing *binary* package ‘ffbase’ ... * DONE (ffbase) [6/45] Installing bitops... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/bitops_1.0-7.tar.gz' Content type 'binary/octet-stream' length 34858 bytes (34 KB) ================================================== downloaded 34 KB [7/45] Installing RCurl... * installing *binary* package ‘bitops’ ... * DONE (bitops) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RCurl_1.98-1.3.tar.gz' Content type 'binary/octet-stream' length 1123996 bytes (1.1 MB) ================================================== downloaded 1.1 MB * installing *binary* package ‘RCurl’ ... [8/45] Installing jsonlite... * DONE (RCurl) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/jsonlite_1.7.2.tar.gz' Content type 'binary/octet-stream' length 536284 bytes (523 KB) ================================================== downloaded 523 KB [9/45] Installing h2o... * installing *binary* package ‘jsonlite’ ... * DONE (jsonlite) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/h2o_3.32.0.1.tar.gz' Content type 'binary/octet-stream' length 166216079 bytes (158.5 MB) ================================================== downloaded 158.5 MB * installing *binary* package ‘h2o’ ... * DONE (h2o) [10/45] Installing curl... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/curl_4.3.tar.gz' Content type 'binary/octet-stream' length 785472 bytes (767 KB) ================================================== downloaded 767 KB * installing *binary* package ‘curl’ ... * DONE (curl) [11/45] Installing mime... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/mime_0.10.tar.gz' Content type 'binary/octet-stream' length 37505 bytes (36 KB) ================================================== downloaded 36 KB [12/45] Installing openssl... * installing *binary* package ‘mime’ ... * DONE (mime) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘sys’, ‘askpass’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/sys_3.4.tar.gz' Content type 'binary/octet-stream' length 54878 bytes (53 KB) ================================================== downloaded 53 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/askpass_1.1.tar.gz' Content type 'binary/octet-stream' length 23556 bytes (23 KB) ================================================== downloaded 23 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/openssl_1.4.3.tar.gz' Content type 'binary/octet-stream' length 1390258 bytes (1.3 MB) ================================================== downloaded 1.3 MB * installing *binary* package ‘sys’ ... * DONE (sys) * installing *binary* package ‘askpass’ ... * DONE (askpass) [13/45] Installing httr... * installing *binary* package ‘openssl’ ... * DONE (openssl) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/httr_1.4.2.tar.gz' Content type 'binary/octet-stream' length 497896 bytes (486 KB) ================================================== downloaded 486 KB [14/45] Installing igraph... * installing *binary* package ‘httr’ ... * DONE (httr) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/igraph_1.2.6.tar.gz' Content type 'binary/octet-stream' length 8427431 bytes (8.0 MB) ================================================== downloaded 8.0 MB * installing *binary* package ‘igraph’ ... * DONE (igraph) [15/45] Installing bit64... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/bit64_4.0.5.tar.gz' Content type 'binary/octet-stream' length 575643 bytes (562 KB) ================================================== downloaded 562 KB [16/45] Installing blob... * installing *binary* package ‘bit64’ ... * DONE (bit64) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/blob_1.2.1.tar.gz' Content type 'binary/octet-stream' length 45560 bytes (44 KB) ================================================== downloaded 44 KB * installing *binary* package ‘blob’ ... * DONE (blob) [17/45] Installing hms... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/hms_1.0.0.tar.gz' Content type 'binary/octet-stream' length 96139 bytes (93 KB) ================================================== downloaded 93 KB * installing *binary* package ‘hms’ ... [18/45] Installing odbc... * DONE (hms) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/odbc_1.3.2.tar.gz' Content type 'binary/octet-stream' length 3340397 bytes (3.2 MB) ================================================== downloaded 3.2 MB * installing *binary* package ‘odbc’ ... [19/45] Installing RcppEigen... * DONE (odbc) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RcppEigen_0.3.3.9.1.tar.gz' Content type 'binary/octet-stream' length 7459406 bytes (7.1 MB) ================================================== downloaded 7.1 MB * installing *binary* package ‘RcppEigen’ ... * DONE (RcppEigen) [20/45] Installing ranger... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ranger_0.12.1.tar.gz' Content type 'binary/octet-stream' length 4264470 bytes (4.1 MB) ================================================== downloaded 4.1 MB * installing *binary* package ‘ranger’ ... [21/45] Installing clipr... * DONE (ranger) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/clipr_0.7.1.tar.gz' Content type 'binary/octet-stream' length 47153 bytes (46 KB) ================================================== downloaded 46 KB * installing *binary* package ‘clipr’ ... * DONE (clipr) [22/45] Installing readr... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/readr_1.4.0.tar.gz' Content type 'binary/octet-stream' length 4711345 bytes (4.5 MB) ================================================== downloaded 4.5 MB * installing *binary* package ‘readr’ ... * DONE (readr) [23/45] Installing haven... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘forcats’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/forcats_0.5.1.tar.gz' Content type 'binary/octet-stream' length 353624 bytes (345 KB) ================================================== downloaded 345 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/haven_2.4.1.tar.gz' Content type 'binary/octet-stream' length 1493299 bytes (1.4 MB) ================================================== downloaded 1.4 MB * installing *binary* package ‘forcats’ ... * DONE (forcats) * installing *binary* package ‘haven’ ... [24/45] Installing readxl... * DONE (haven) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘rematch’, ‘prettyunits’, ‘cellranger’, ‘progress’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rematch_1.0.1.tar.gz' Content type 'binary/octet-stream' length 11905 bytes (11 KB) ================================================== downloaded 11 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/prettyunits_1.1.1.tar.gz' Content type 'binary/octet-stream' length 34423 bytes (33 KB) ================================================== downloaded 33 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cellranger_1.1.0.tar.gz' Content type 'binary/octet-stream' length 101054 bytes (98 KB) ================================================== downloaded 98 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/progress_1.2.2.tar.gz' Content type 'binary/octet-stream' length 83277 bytes (81 KB) ================================================== downloaded 81 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/readxl_1.3.1.tar.gz' Content type 'binary/octet-stream' length 2947206 bytes (2.8 MB) ================================================== downloaded 2.8 MB * installing *binary* package ‘rematch’ ... * DONE (rematch) * installing *binary* package ‘prettyunits’ ... * DONE (prettyunits) * installing *binary* package ‘cellranger’ ... * DONE (cellranger) * installing *binary* package ‘progress’ ... * DONE (progress) * installing *binary* package ‘readxl’ ... * DONE (readxl) [25/45] Installing openxlsx... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘zip’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/zip_2.1.1.tar.gz' Content type 'binary/octet-stream' length 636558 bytes (621 KB) ================================================== downloaded 621 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/openxlsx_4.2.3.tar.gz' Content type 'binary/octet-stream' length 4682914 bytes (4.5 MB) ================================================== downloaded 4.5 MB * installing *binary* package ‘zip’ ... * DONE (zip) [26/45] Installing rio... * installing *binary* package ‘openxlsx’ ... * DONE (openxlsx) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rio_0.5.26.tar.gz' Content type 'binary/octet-stream' length 476791 bytes (465 KB) ================================================== downloaded 465 KB * installing *binary* package ‘rio’ ... * DONE (rio) [27/45] Installing RODBC... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RODBC_1.3-17.tar.gz' Content type 'binary/octet-stream' length 868472 bytes (848 KB) ================================================== downloaded 848 KB * installing *binary* package ‘RODBC’ ... [28/45] Installing memoise... * DONE (RODBC) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘fastmap’, ‘cachem’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/fastmap_1.1.0.tar.gz' Content type 'binary/octet-stream' length 240548 bytes (234 KB) ================================================== downloaded 234 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cachem_1.0.4.tar.gz' Content type 'binary/octet-stream' length 68485 bytes (66 KB) ================================================== downloaded 66 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/memoise_2.0.0.tar.gz' Content type 'binary/octet-stream' length 46623 bytes (45 KB) ================================================== downloaded 45 KB * installing *binary* package ‘fastmap’ ... * DONE (fastmap) * installing *binary* package ‘cachem’ ... * DONE (cachem) * installing *binary* package ‘memoise’ ... * DONE (memoise) [29/45] Installing plogr... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/plogr_0.2.0.tar.gz' Content type 'binary/octet-stream' length 12603 bytes (12 KB) ================================================== downloaded 12 KB * installing *binary* package ‘plogr’ ... [30/45] Installing RSQLite... * DONE (plogr) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RSQLite_2.2.7.tar.gz' Content type 'binary/octet-stream' length 5736199 bytes (5.5 MB) ================================================== downloaded 5.5 MB [31/45] Installing selectr... * installing *binary* package ‘RSQLite’ ... * DONE (RSQLite) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/selectr_0.4-2.tar.gz' Content type 'binary/octet-stream' length 485139 bytes (473 KB) ================================================== downloaded 473 KB [32/45] Installing rvest... * installing *binary* package ‘selectr’ ... * DONE (selectr) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rvest_1.0.0.tar.gz' Content type 'binary/octet-stream' length 195912 bytes (191 KB) ================================================== downloaded 191 KB [33/45] Installing assertthat... * installing *binary* package ‘rvest’ ... * DONE (rvest) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/assertthat_0.2.1.tar.gz' Content type 'binary/octet-stream' length 52137 bytes (50 KB) ================================================== downloaded 50 KB * installing *binary* package ‘assertthat’ ... * DONE (assertthat) [34/45] Installing base64enc... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/base64enc_0.1-3.tar.gz' Content type 'binary/octet-stream' length 38865 bytes (37 KB) ================================================== downloaded 37 KB [35/45] Installing config... * installing *binary* package ‘base64enc’ ... * DONE (base64enc) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘yaml’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/yaml_2.2.1.tar.gz' Content type 'binary/octet-stream' length 283644 bytes (276 KB) ================================================== downloaded 276 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/config_0.3.1.tar.gz' Content type 'binary/octet-stream' length 79840 bytes (77 KB) ================================================== downloaded 77 KB * installing *binary* package ‘yaml’ ... * DONE (yaml) * installing *binary* package ‘config’ ... * DONE (config) [36/45] Installing dbplyr... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/dbplyr_2.1.1.tar.gz' Content type 'binary/octet-stream' length 803762 bytes (784 KB) ================================================== downloaded 784 KB [37/45] Installing forge... * installing *binary* package ‘dbplyr’ ... * DONE (dbplyr) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/forge_0.2.0.tar.gz' Content type 'binary/octet-stream' length 38100 bytes (37 KB) ================================================== downloaded 37 KB [38/45] Installing globals... * installing *binary* package ‘forge’ ... * DONE (forge) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/globals_0.14.0.tar.gz' Content type 'binary/octet-stream' length 93164 bytes (90 KB) ================================================== downloaded 90 KB * installing *binary* package ‘globals’ ... * DONE (globals) [39/45] Installing r2d3... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘htmlwidgets’, ‘htmltools’, ‘rstudioapi’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/htmlwidgets_1.5.3.tar.gz' Content type 'binary/octet-stream' length 270838 bytes (264 KB) ================================================== downloaded 264 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/htmltools_0.5.1.1.tar.gz' Content type 'binary/octet-stream' length 236672 bytes (231 KB) ================================================== downloaded 231 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rstudioapi_0.13.tar.gz' Content type 'binary/octet-stream' length 274043 bytes (267 KB) ================================================== downloaded 267 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/r2d3_0.2.5.tar.gz' Content type 'binary/octet-stream' length 659457 bytes (644 KB) ================================================== downloaded 644 KB * installing *binary* package ‘htmltools’ ... * DONE (htmltools) * installing *binary* package ‘rstudioapi’ ... * DONE (rstudioapi) * installing *binary* package ‘htmlwidgets’ ... * DONE (htmlwidgets) * installing *binary* package ‘r2d3’ ... [40/45] Installing rappdirs... * DONE (r2d3) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rappdirs_0.3.3.tar.gz' Content type 'binary/octet-stream' length 47356 bytes (46 KB) ================================================== downloaded 46 KB [41/45] Installing rprojroot... * installing *binary* package ‘rappdirs’ ... * DONE (rappdirs) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rprojroot_2.0.2.tar.gz' Content type 'binary/octet-stream' length 96727 bytes (94 KB) ================================================== downloaded 94 KB * installing *binary* package ‘rprojroot’ ... * DONE (rprojroot) [42/45] Installing rstudioapi... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rstudioapi_0.13.tar.gz' Content type 'binary/octet-stream' length 274043 bytes (267 KB) ================================================== downloaded 267 KB * installing *binary* package ‘rstudioapi’ ... * DONE (rstudioapi) [43/45] Installing uuid... The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/uuid_0.1-4.tar.gz' Content type 'binary/octet-stream' length 34655 bytes (33 KB) ================================================== downloaded 33 KB [44/45] Installing sparklyr... * installing *binary* package ‘uuid’ ... * DONE (uuid) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/sparklyr_1.6.2.tar.gz' Content type 'binary/octet-stream' length 5253486 bytes (5.0 MB) ================================================== downloaded 5.0 MB [45/45] Installing XML... * installing *binary* package ‘sparklyr’ ... * DONE (sparklyr) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/XML_3.99-0.6.tar.gz' Content type 'binary/octet-stream' length 1945020 bytes (1.9 MB) ================================================== downloaded 1.9 MB * installing *binary* package ‘XML’ ... * DONE (XML) The downloaded source packages are in ‘/tmp/Rtmp4ys6Gr/downloaded_packages’ ✔ Packages successfully installed. やはりエラー > # load the credit dataset > credit <- read.csv("credit.csv", stringsAsFactors = TRUE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'credit.csv': No such file or directory
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

今日のdocker error

今日のdocker error Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio ついつい、書いてあることと違うことをした。 bash $ docker run --rm -p 8787:8787 rocker/rstudio -it /bin/bash Unable to find image 'rocker/rstudio:latest' locally latest: Pulling from rocker/rstudio a70d879fa598: Pull complete c4394a92d1f8: Pull complete 10e6159c56c0: Pull complete 833bebb909e4: Pull complete 9bceb8b50184: Pull complete e925a327b30d: Pull complete 01c3425e0ade: Pull complete Digest: sha256:109863d20ff03446fa87aad09004d307c2795d8f62054f34805aa16a0a25518d Status: Downloaded newer image for rocker/rstudio:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-it\": executable file not found in $PATH": unknown. みごとにエラッた。 bash $ docker run --rm -p 8787:8787 rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... ERROR: You must set a unique PASSWORD (not 'rstudio') first! e.g. run with: docker run -e PASSWORD=<YOUR_PASS> -p 8787:8787 rocker/rstudio [cont-init.d] userconf: exited 1. [cont-init.d] done. [services.d] starting services [services.d] done. ^C [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting. パスワード省略してもいいって書いてなかったっけ。 $ docker run --rm -p 8787:8787 -e PASSWORD=password rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... [cont-init.d] userconf: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. 26 Apr 2021 12:16:28 [rserver] ERROR system error 2 (No such file or directory) [description: User not found., user-value: user-value]; OCCURRED AT rstudio::core::Error rstudio::core::system::User::Impl::populateUser(rstudio::core::system::User::Impl::GetPasswdFunc<T>&, T) [with T = const char* rstudio::core::system::User::Impl::GetPasswdFunc<T> = std::function<int(const char*, passwd*, char*, long unsigned int, passwd**)>] src/cpp/shared_core/system/User.cpp:68; LOGGED FROM: std::__cxx11::string rstudio::server::pam_auth::{anonymous}::userIdentifierToLocalUsername(const string&) src/cpp/server/ServerPAMAuth.cpp:96
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

今日のdocker error (解決)

今日のdocker error Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio ついつい、書いてあることと違うことをした。 bash $ docker run --rm -p 8787:8787 rocker/rstudio -it /bin/bash Unable to find image 'rocker/rstudio:latest' locally latest: Pulling from rocker/rstudio a70d879fa598: Pull complete c4394a92d1f8: Pull complete 10e6159c56c0: Pull complete 833bebb909e4: Pull complete 9bceb8b50184: Pull complete e925a327b30d: Pull complete 01c3425e0ade: Pull complete Digest: sha256:109863d20ff03446fa87aad09004d307c2795d8f62054f34805aa16a0a25518d Status: Downloaded newer image for rocker/rstudio:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-it\": executable file not found in $PATH": unknown. みごとにエラッた。 bash $ docker run --rm -p 8787:8787 rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... ERROR: You must set a unique PASSWORD (not 'rstudio') first! e.g. run with: docker run -e PASSWORD=<YOUR_PASS> -p 8787:8787 rocker/rstudio [cont-init.d] userconf: exited 1. [cont-init.d] done. [services.d] starting services [services.d] done. ^C [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting. パスワード省略してもいいって書いてなかったっけ。 $ docker run --rm -p 8787:8787 -e PASSWORD=password rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... [cont-init.d] userconf: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. 26 Apr 2021 12:16:28 [rserver] ERROR system error 2 (No such file or directory) [description: User not found., user-value: user-value]; OCCURRED AT rstudio::core::Error rstudio::core::system::User::Impl::populateUser(rstudio::core::system::User::Impl::GetPasswdFunc<T>&, T) [with T = const char* rstudio::core::system::User::Impl::GetPasswdFunc<T> = std::function<int(const char*, passwd*, char*, long unsigned int, passwd**)>] src/cpp/shared_core/system/User.cpp:68; LOGGED FROM: std::__cxx11::string rstudio::server::pam_auth::{anonymous}::userIdentifierToLocalUsername(const string&) src/cpp/server/ServerPAMAuth.cpp:96 Docker でユーザ名を指定してコンテナを起動する https://qiita.com/syoyo/items/6fa6597b7a6625000e33 bash $ docker run --rm -p 8787:8787 -u kiyoshi -e PASSWORD=password rocker/rstudio docker: Error response from daemon: unable to find user kiyoshi: no matching entries in passwd file. Visit localhost:8787 in your browser and log in with username rstudio and the password you set. NB: Setting a password is now REQUIRED. Container will error otherwise. あ、userはrstudioだって書いてあった。 入れた。ありがと。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

今日のdocker error: RStudio (解決)

今日のdocker error Using the rocker/rstudio container https://hub.docker.com/r/rocker/rstudio ついつい、書いてあることと違うことをした。 bash $ docker run --rm -p 8787:8787 rocker/rstudio -it /bin/bash Unable to find image 'rocker/rstudio:latest' locally latest: Pulling from rocker/rstudio a70d879fa598: Pull complete c4394a92d1f8: Pull complete 10e6159c56c0: Pull complete 833bebb909e4: Pull complete 9bceb8b50184: Pull complete e925a327b30d: Pull complete 01c3425e0ade: Pull complete Digest: sha256:109863d20ff03446fa87aad09004d307c2795d8f62054f34805aa16a0a25518d Status: Downloaded newer image for rocker/rstudio:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-it\": executable file not found in $PATH": unknown. みごとにエラッた。 bash $ docker run --rm -p 8787:8787 rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... ERROR: You must set a unique PASSWORD (not 'rstudio') first! e.g. run with: docker run -e PASSWORD=<YOUR_PASS> -p 8787:8787 rocker/rstudio [cont-init.d] userconf: exited 1. [cont-init.d] done. [services.d] starting services [services.d] done. ^C [cont-finish.d] executing container finish scripts... [cont-finish.d] done. [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting. パスワード省略してもいいって書いてなかったっけ。 $ docker run --rm -p 8787:8787 -e PASSWORD=password rocker/rstudio [s6-init] making user provided files available at /var/run/s6/etc...exited 0. [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] userconf: executing... [cont-init.d] userconf: exited 0. [cont-init.d] done. [services.d] starting services [services.d] done. 26 Apr 2021 12:16:28 [rserver] ERROR system error 2 (No such file or directory) [description: User not found., user-value: user-value]; OCCURRED AT rstudio::core::Error rstudio::core::system::User::Impl::populateUser(rstudio::core::system::User::Impl::GetPasswdFunc<T>&, T) [with T = const char* rstudio::core::system::User::Impl::GetPasswdFunc<T> = std::function<int(const char*, passwd*, char*, long unsigned int, passwd**)>] src/cpp/shared_core/system/User.cpp:68; LOGGED FROM: std::__cxx11::string rstudio::server::pam_auth::{anonymous}::userIdentifierToLocalUsername(const string&) src/cpp/server/ServerPAMAuth.cpp:96 Docker でユーザ名を指定してコンテナを起動する https://qiita.com/syoyo/items/6fa6597b7a6625000e33 bash $ docker run --rm -p 8787:8787 -u kiyoshi -e PASSWORD=password rocker/rstudio docker: Error response from daemon: unable to find user kiyoshi: no matching entries in passwd file. Visit localhost:8787 in your browser and log in with username rstudio and the password you set. NB: Setting a password is now REQUIRED. Container will error otherwise. あ、userはrstudioだって書いてあった。 入れた。ありがと。 ファイルエラー 「「Rによる機械学習」の勉強履歴(1)」後追い https://qiita.com/kaizen_nagoya/items/68170a86b1b3dd5e596b 第3章のファイルを読み込んで Runしたら Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'wisc_bc_data.csv': No such file or directory ファイルはあるのに。 第4章でも、 > # read the sms data into the sms data frame > sms_raw <- read.csv("sms_spam.csv", stringsAsFactors = FALSE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'sms_spam.csv': No such file or directory library 第4章のライブラリは大きかった。無事導入。 ** Installing R Packages: 'e1071', 'SnowballC', 'tm', 'wordcloud' [1/11] Installing proxy... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/proxy_0.4-25.tar.gz' Content type 'binary/octet-stream' length 251003 bytes (245 KB) ================================================== downloaded 245 KB [2/11] Installing e1071... * installing *binary* package ‘proxy’ ... * DONE (proxy) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/e1071_1.7-6.tar.gz' Content type 'binary/octet-stream' length 919381 bytes (897 KB) ================================================== downloaded 897 KB [3/11] Installing SnowballC... * installing *binary* package ‘e1071’ ... * DONE (e1071) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SnowballC_0.7.0.tar.gz' Content type 'binary/octet-stream' length 631384 bytes (616 KB) ================================================== downloaded 616 KB * installing *binary* package ‘SnowballC’ ... * DONE (SnowballC) [4/11] Installing NLP... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/NLP_0.2-1.tar.gz' Content type 'binary/octet-stream' length 384436 bytes (375 KB) ================================================== downloaded 375 KB * installing *binary* package ‘NLP’ ... * DONE (NLP) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ [5/11] Installing Rcpp... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Rcpp_1.0.6.tar.gz' Content type 'binary/octet-stream' length 4150785 bytes (4.0 MB) ================================================== downloaded 4.0 MB * installing *binary* package ‘Rcpp’ ... * DONE (Rcpp) [6/11] Installing slam... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/slam_0.1-48.tar.gz' Content type 'binary/octet-stream' length 221661 bytes (216 KB) ================================================== downloaded 216 KB [7/11] Installing xml2... * installing *binary* package ‘slam’ ... * DONE (slam) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xml2_1.3.2.tar.gz' Content type 'binary/octet-stream' length 616796 bytes (602 KB) ================================================== downloaded 602 KB * installing *binary* package ‘xml2’ ... * DONE (xml2) [8/11] Installing BH... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/BH_1.75.0-0.tar.gz' Content type 'binary/octet-stream' length 11877438 bytes (11.3 MB) ================================================== downloaded 11.3 MB * installing *binary* package ‘BH’ ... * DONE (BH) [9/11] Installing tm... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tm_0.7-8.tar.gz' Content type 'binary/octet-stream' length 1440316 bytes (1.4 MB) ================================================== downloaded 1.4 MB [10/11] Installing RColorBrewer... * installing *binary* package ‘tm’ ... * DONE (tm) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RColorBrewer_1.1-2.tar.gz' Content type 'binary/octet-stream' length 52761 bytes (51 KB) ================================================== downloaded 51 KB * installing *binary* package ‘RColorBrewer’ ... * DONE (RColorBrewer) [11/11] Installing wordcloud... The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/wordcloud_2.6.tar.gz' Content type 'binary/octet-stream' length 448713 bytes (438 KB) ================================================== downloaded 438 KB * installing *binary* package ‘wordcloud’ ... * DONE (wordcloud) The downloaded source packages are in ‘/tmp/RtmpIKZJLE/downloaded_packages’ ✔ Packages successfully installed. 第5章 ** Installing R Packages: 'C50', 'OneR', 'RWeka' [1/7] Installing partykit... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘libcoin’, ‘mvtnorm’, ‘Formula’, ‘inum’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/libcoin_1.0-8.tar.gz' Content type 'binary/octet-stream' length 1052493 bytes (1.0 MB) ================================================== downloaded 1.0 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/mvtnorm_1.1-1.tar.gz' Content type 'binary/octet-stream' length 262905 bytes (256 KB) ================================================== downloaded 256 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Formula_1.2-4.tar.gz' Content type 'binary/octet-stream' length 175098 bytes (170 KB) ================================================== downloaded 170 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/inum_1.0-4.tar.gz' Content type 'binary/octet-stream' length 36473 bytes (35 KB) ================================================== downloaded 35 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/partykit_1.2-13.tar.gz' Content type 'binary/octet-stream' length 2425357 bytes (2.3 MB) ================================================== downloaded 2.3 MB * installing *binary* package ‘mvtnorm’ ... * DONE (mvtnorm) * installing *binary* package ‘Formula’ ... * DONE (Formula) * installing *binary* package ‘libcoin’ ... * DONE (libcoin) * installing *binary* package ‘inum’ ... * DONE (inum) [2/7] Installing Cubist... * installing *binary* package ‘partykit’ ... * DONE (partykit) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependencies ‘glue’, ‘magrittr’, ‘stringi’, ‘plyr’, ‘stringr’, ‘reshape2’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/glue_1.4.2.tar.gz' Content type 'binary/octet-stream' length 144331 bytes (140 KB) ================================================== downloaded 140 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/magrittr_2.0.1.tar.gz' Content type 'binary/octet-stream' length 232440 bytes (226 KB) ================================================== downloaded 226 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/stringi_1.5.3.tar.gz' Content type 'binary/octet-stream' length 2902983 bytes (2.8 MB) ================================================== downloaded 2.8 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/plyr_1.8.6.tar.gz' Content type 'binary/octet-stream' length 1153520 bytes (1.1 MB) ================================================== downloaded 1.1 MB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/stringr_1.4.0.tar.gz' Content type 'binary/octet-stream' length 204624 bytes (199 KB) ================================================== downloaded 199 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/reshape2_1.4.4.tar.gz' Content type 'binary/octet-stream' length 537015 bytes (524 KB) ================================================== downloaded 524 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Cubist_0.2.3.tar.gz' Content type 'binary/octet-stream' length 649064 bytes (633 KB) ================================================== downloaded 633 KB * installing *binary* package ‘glue’ ... * DONE (glue) * installing *binary* package ‘magrittr’ ... * DONE (magrittr) * installing *binary* package ‘stringi’ ... * DONE (stringi) * installing *binary* package ‘plyr’ ... * DONE (plyr) * installing *binary* package ‘stringr’ ... * DONE (stringr) * installing *binary* package ‘reshape2’ ... * DONE (reshape2) [3/7] Installing C50... * installing *binary* package ‘Cubist’ ... * DONE (Cubist) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/C50_0.1.3.1.tar.gz' Content type 'binary/octet-stream' length 604693 bytes (590 KB) ================================================== downloaded 590 KB * installing *binary* package ‘C50’ ... * DONE (C50) [4/7] Installing OneR... The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/OneR_2.2.tar.gz' Content type 'binary/octet-stream' length 106149 bytes (103 KB) ================================================== downloaded 103 KB [5/7] Installing RWekajars... * installing *binary* package ‘OneR’ ... * DONE (OneR) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘rJava’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rJava_0.9-13.tar.gz' Content type 'binary/octet-stream' length 933124 bytes (911 KB) ================================================== downloaded 911 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RWekajars_3.9.3-2.tar.gz' Content type 'binary/octet-stream' length 10028473 bytes (9.6 MB) ================================================== downloaded 9.6 MB * installing *binary* package ‘rJava’ ... * DONE (rJava) [6/7] Installing rJava... * installing *binary* package ‘RWekajars’ ... * DONE (RWekajars) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rJava_0.9-13.tar.gz' Content type 'binary/octet-stream' length 933124 bytes (911 KB) ================================================== downloaded 911 KB * installing *binary* package ‘rJava’ ... [7/7] Installing RWeka... * DONE (rJava) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RWeka_0.4-43.tar.gz' Content type 'binary/octet-stream' length 626084 bytes (611 KB) ================================================== downloaded 611 KB * installing *binary* package ‘RWeka’ ... * DONE (RWeka) The downloaded source packages are in ‘/tmp/Rtmpe0fskr/downloaded_packages’ ✔ Packages successfully installed. 第6章 ** Installing R Packages: 'psych', 'rpart.plot' [1/3] Installing mnormt... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) also installing the dependency ‘tmvnsim’ trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/tmvnsim_1.0-2.tar.gz' Content type 'binary/octet-stream' length 25085 bytes (24 KB) ================================================== downloaded 24 KB trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/mnormt_2.0.2.tar.gz' Content type 'binary/octet-stream' length 187894 bytes (183 KB) ================================================== downloaded 183 KB * installing *binary* package ‘tmvnsim’ ... * DONE (tmvnsim) [2/3] Installing psych... * installing *binary* package ‘mnormt’ ... * DONE (mnormt) The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/psych_2.1.3.tar.gz' Content type 'binary/octet-stream' length 4093812 bytes (3.9 MB) ================================================== downloaded 3.9 MB * installing *binary* package ‘psych’ ... * DONE (psych) [3/3] Installing rpart.plot... The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/rpart.plot_3.0.9.tar.gz' Content type 'binary/octet-stream' length 1012900 bytes (989 KB) ================================================== downloaded 989 KB * installing *binary* package ‘rpart.plot’ ... * DONE (rpart.plot) The downloaded source packages are in ‘/tmp/Rtmpxk6aTn/downloaded_packages’ ✔ Packages successfully installed. 実行はエラー:ファイルあるのに。 > ## Understanding regression ---- > ## Example: Space Shuttle Launch Data ---- > launch <- read.csv("challenger.csv") Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'challenger.csv': No such file or directory 第7章 ** Installing R Packages: 'kernlab', 'neuralnet' [1/3] Installing kernlab... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/kernlab_0.9-29.tar.gz' Content type 'binary/octet-stream' length 2525692 bytes (2.4 MB) ================================================== downloaded 2.4 MB * installing *binary* package ‘kernlab’ ... * DONE (kernlab) [2/3] Installing Deriv... The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Deriv_4.1.3.tar.gz' Content type 'binary/octet-stream' length 146530 bytes (143 KB) ================================================== downloaded 143 KB [3/3] Installing neuralnet... * installing *binary* package ‘Deriv’ ... * DONE (Deriv) The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/neuralnet_1.44.2.tar.gz' Content type 'binary/octet-stream' length 121398 bytes (118 KB) ================================================== downloaded 118 KB * installing *binary* package ‘neuralnet’ ... * DONE (neuralnet) The downloaded source packages are in ‘/tmp/RtmpHUOv86/downloaded_packages’ ✔ Packages successfully installed. これもエラー > ## Step 2: Exploring and preparing the data ---- > # read in data and examine structure > concrete <- read.csv("concrete.csv") Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'concrete.csv': No such file or directory 第8章 Installing 'arules' ... Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/arules_1.6-7.tar.gz' Content type 'binary/octet-stream' length 2650723 bytes (2.5 MB) ================================================== downloaded 2.5 MB * installing *binary* package ‘arules’ ... * DONE (arules) The downloaded source packages are in ‘/tmp/RtmpPlEr9q/downloaded_packages’ ✔ Package 'arules' successfully installed. で、 > groceries <- read.transactions("groceries.csv", sep = ",") Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'groceries.csv': No such file or directory
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Dockerでdjangoの開発環境

docker-compose-django/ ├ docker ┬ python ┬ Dockerfile │ │ └ requirements.txt │ └ web ─ default.conf │ ├ docker-compose.yml ├ django-project ├ django-app ├ static ├ templates └ manage.py webコンテナ、dbコンテナ、appコンテナの3つを立ち上げる。 appコンテナのイメージはDockerfileより作成。 docker-compose.yml version: '3' # コンテナ services: # コンテナ1 web: image: nginx:1.17.7 ports: - '80:80' # ローカルポート80とDockerポート80を繋げる depends_on: - app # appが立ち上がった後に起動 volumes: - ./docker/web/default.conf:/etc/nginx/conf.d/default.conf # ゲストosの./docker/webにあるdefault.confとコンテナ/etc/nginx/conf.dにあるdefault.confと繋げる - gunicorn:/var/run/gunicorn # ゲストosの現在のディレクトリとコンテナ/var/run/gunicornを繋げる - ./static:/static # コンテナ2 app: build: ./docker/python # imageの代わりに./docker/phpにあるDockerfileからコンテナを作成 restart: always volumes: - .:/work - gunicorn:/var/run/gunicorn - ./static:/work/static # nginxを使わない場合portを指定し、pythonのサーバーを起動 # command: python manage.py runserver 0.0.0.0:8000 #ports: # - 8000:8000 depends_on: - mysql # mysqlが立ち上がった後に起動 # コンテナ3 mysql: image: mysql:5.7 environment: MYSQL_DATABASE: sample MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: password # Mysqlの設定をここに記載する ports: - "3306:3306" volumes: - mysql-data:/var/lib/mysql # ボリュームを作成 volumes: mysql-data: gunicorn: driver: local # mysql-dataというディレクトリをDockerに作成するイメージ Dockerfile FROM python:3.9-slim #slimの場合osがubuntu WORKDIR /work ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN apt-get update && \ apt-get -y install gcc libmariadb-dev RUN apt-get install -y nodejs npm #npmを使うためにインストール RUN pip install --upgrade pip && pip install pipenv COPY ./requirements.txt /work/requirements.txt RUN pip install -r requirements.txt RUN mkdir -p /var/run/gunicorn #nginxとgunicornを接続するコマンド CMD ["gunicorn", "mysite.wsgi", "--bind=unix:/var/run/gunicorn/gunicorn.sock"] requirements.txt Django==3.0.2 mysqlclient==1.4.6 #mysqlを使う場合に必要 djangorestframework>=3.11.0, <3.12.0 gunicorn==20.0.4 whitenoise==5.2.0 settings.py """ Django settings for mysite project. Generated by 'django-admin startproject' using Django 2.1.11. For more information on this file, see https://docs.djangoproject.com/en/2.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.1/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls', 'rest_framework', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'mysite.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR, 'templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases #詳細はdocker-compose.ymlのenviroment DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'sample', 'USER': 'user', 'PASSWORD': 'password', # dockerのコンテナ名 'HOST': 'docker-compose-django_mysql_1', 'PORT': '3306', } } # Password validation # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True STATIC_ROOT = os.path.join(BASE_DIR, "static") STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_URL = '/static/' default.conf upstream gunicorn-django { server unix:///var/run/gunicorn/gunicorn.sock; } server { listen 80; server_name localhost; location / { try_files $uri @gunicorn; } location @gunicorn { proxy_pass http://gunicorn-django; } # カーレントディレクトリの./staticとnginxのディレクトリ/staticを繋げているので以下のような設定が必要 location /static { alias /static/; } } さぁ立ち上げよう。 terminal docker-compose up -d よく使ったコマンド。 docker-compose down docker-compose down --rmi all --remove-orphans docker exec -it docker-compose-django_app_1 bash docker exec -it docker-compose-django_app_1 python3 manage.py runserver 0.0.0.0:8000 docker-compose run web python manage.py collectstatic --noinput mysql -u root -p 間違っているところもあると思うので、共有して頂けると非常に助かります。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

[メモ]Dockerの環境構築+Rails APIモードのまとめ

初めに 最近はDockerとRailsのAPIモードを学習してるので、 学んだことをまとめてメモしておきます。 まずはDocker環境構築から Dockerの環境構築は主に以下の記事の参考で作成していきます。 最初はまず作業用のファイルを用意します $ mkdir myapp Dockerfile作成 rubyのバージョンは自分が今使ってる2.7.2に変更してみます。 Dockerfile FROM ruby:2.7.2 RUN apt-get update -qq && apt-get install -y nodejs postgresql-client RUN apt-get update && apt-get install -y curl apt-transport-https wget && \ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update && apt-get install -y yarn RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - && \ apt-get install nodejs RUN mkdir /myapp WORKDIR /myapp COPY Gemfile /myapp/Gemfile COPY Gemfile.lock /myapp/Gemfile.lock RUN bundle install COPY . /myapp # Add a script to be executed every time the container starts. COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT ["entrypoint.sh"] EXPOSE 3000 # Start the main process. CMD ["rails", "server", "-b", "0.0.0.0"] P.S.Docker 入門 1項目ずつ理解するでは、Dockerfileの書き方について分かりやすく説明していますので、是非ご参考ください。 Gemfile作成 myapp/Gemfile source 'https://rubygems.org' gem 'rails', '~> 6' Gemfile.lock 作成 $ touch Gemfile.lock 中身は空のままでオッケー entrypoint.sh作成 $ touch entrypoint.sh myapp/entrypoint.sh #!/bin/bash set -e # Remove a potentially pre-existing server.pid for Rails. rm -f /myapp/tmp/pids/server.pid # Then exec the container's main process (what's set as CMD in the Dockerfile). exec "$@" docker-compose.yml 作成 $ touch docker-compose.yml myapp/docker-compose.yml version: "3.9" services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data environment: POSTGRES_HOST_AUTH_METHOD: 'trust' web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/myapp ports: - "3000:3000" depends_on: - db P.S.Docker 入門 1項目ずつ理解する これで下準備完了 ファイルの中はこんな感じ: myapp - Dockerfile - Gemfile - Gemfile.lock - entrypoint.sh - docker-compose.yml いよいよRails new 今回RailsのAPI開発モードを利用していますので、--apiオプションを使います。 -Tはデフォルトのテスティングフレームワーク「Minitest」をオフにするオプションです。 APIモード使わない場合は--apiを自由に削除してください。 $ docker-compose run web rails new . --force --no-deps --database=postgresql --api -T ls -lコマンドでみると。。。 $ ls -l total 64 -rw-r--r-- 1 tsuki_ staff 831 Apr 24 23:02 Dockerfile -rw-r--r-- 1 tsuki_ staff 1397 Apr 24 23:48 Gemfile -rw-r--r-- 1 tsuki_ staff 4022 Apr 24 23:48 Gemfile.lock -rw-r--r-- 1 tsuki_ staff 374 Apr 24 23:48 README.md -rw-r--r-- 1 tsuki_ staff 227 Apr 24 23:48 Rakefile drwxr-xr-x 8 tsuki_ staff 256 Apr 24 23:48 app drwxr-xr-x 7 tsuki_ staff 224 Apr 24 23:48 bin drwxr-xr-x 16 tsuki_ staff 512 Apr 24 23:48 config -rw-r--r-- 1 tsuki_ staff 160 Apr 24 23:48 config.ru drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 db -rw-r--r-- 1 tsuki_ staff 366 Apr 24 23:29 docker-compose.yml -rw-r--r-- 1 tsuki_ staff 201 Apr 24 23:23 entrypoint.sh drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 lib drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 log drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 public drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 storage drwxr-xr-x 7 tsuki_ staff 224 Apr 24 23:48 tmp drwxr-xr-x 3 tsuki_ staff 96 Apr 24 23:48 vendor 無事にRailsが生成されてますね! bundle install $ docker-compose build ぬぬ!?エラーが出ました ...[前略] ------ > [ 9/12] RUN bundle install: #14 0.294 /usr/local/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (1.17.2) required by your /myapp/Gemfile.lock. (Gem::GemNotFoundException) #14 0.294 To update to the latest version installed on your system, run `bundle update --bundler`. #14 0.294 To install the missing version, run `gem install bundler:1.17.2` #14 0.296 from /usr/local/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path' #14 0.296 from ------ ...[後略] run `gem install bundler:1.17.2` と書いたので、追加してみます。 Dockerfile RUN mkdir /myapp WORKDIR /myapp COPY Gemfile /myapp/Gemfile COPY Gemfile.lock /myapp/Gemfile.lock ########追加########### RUN gem install bundler:1.17.2 ###################### RUN bundle install COPY . /myapp はい、$ docker-compose build ぬぬ!?また新しいエラーが出てきました。 ...[前略] ------ > [10/13] RUN bundle install: #14 0.734 Your Ruby version is 2.7.2, but your Gemfile specified 2.6.5 ------ ...[後略] そっか、GemfileのRubyバージョンは2.6.5だったのか はい、変更! Gemfile #変更前 ruby '2.6.5' #変更後 ruby '2.7.2' 。。。 はい、$ docker-compose build! ...[前略] Successfully built..... ...[後略] 今度こそ無事にできたんですね! DBへの接続設定 Railsのconfig/database.ymlファイルを、下記のように書き換えます。 database.yml default: &default adapter: postgresql encoding: unicode host: db username: postgres password: pool: 5 development: <<: *default database: myapp_development test: <<: *default database: myapp_test Dockerコンテナの起動 では、Dockerを起動してみます。 $ docker-compose up したら、安心する画面ができましたね! ...[前略] web_1 | => Booting Puma web_1 | => Rails 6.1.3.1 application starting in development web_1 | => Run `bin/rails server --help` for more startup options web_1 | Puma starting in single mode... web_1 | * Puma version: 5.2.2 (ruby 2.7.2-p137) ("Fettisdagsbulle") web_1 | * Min threads: 5 web_1 | * Max threads: 5 web_1 | * Environment: development web_1 | * PID: 1 web_1 | * Listening on http://0.0.0.0:3000 web_1 | Use Ctrl-C to stop http://0.0.0.0:3000にアクセスしてみると ぬぬ!?またエラーの画面が出てきました。 ...[前略] web_1 | ActiveRecord::NoDatabaseError (FATAL: database "myapp_development" does not exist web_1 | ): ...[後略] そかそかdatebaseの問題ね! では一旦 $ docker-compose down P.s.筆者はもう一つターミナルを開いて実行していますが、 こちらの【Docker超入門 #7】Docker ComposeでRailsを構築しようの19:55からのところは、 docker-compose upをバックグラウンドで実行してくれることについて説明がありますので、 必要な方は是非参考してみてください。 DB作成 $ docker-compose run web rails db:create そして $ docker-compose up 無事に環境構築できたそうですね!! Dockerの環境でAPIモードでAPIを作ってみよう この記事の参考で、Docker内でAPIを作っていきます。 テスト環境 まずはテスト環境を先に用意していきます。今回はRspecを使います。 Gemfile group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] #⇩追加 gem 'rspec-rails' end そしてdocker-compose buildでbundle install 次はこちらの記事:dockerでよく使うコマンド一覧【Rails】で学んだDockerのコマンドで Rspecのインストールを行います。 $ docker-compose run web bundle exec rails g rspec:install それでspecファイルが生成されます。 モデル.コントローラの作成 では今回は簡単なタスク機能のアプリを作っていきます。 $ docker-compose run web bundle exec rails g model post title:string content:text $ docker-compose run web bundle exec rails g controller posts $ docker-compose run web bundle exec rails db:create $ docker-compose run web bundle exec rails db:migrate ルーティングの設定 config/routes.rb Rails.application.routes.draw do namespace 'api' do namespace 'v1' do resources :posts end end end コントローラの設定 ルートで設定した名前空間に合わせてディレクトリの構成を以下のようにします。 controllers/api/v1/posts_controller.rb module Api module V1 class PostsController < ApplicationController before_action :set_post, only: [:show, :update, :destroy] def index posts = Post.order(created_at: :desc) render json: { status: 'SUCCESS', message: 'Loaded posts', data: posts } end def show render json: { status: 'SUCCESS', message: 'Loaded the post', data: @post } end def create post = Post.new(post_params) if post.save render json: { status: 'SUCCESS', data: post } else render json: { status: 'ERROR', data: post.errors } end end def destroy @post.destroy render json: { status: 'SUCCESS', message: 'Deleted the post', data: @post } end def update if @post.update(post_params) render json: { status: 'SUCCESS', message: 'Updated the post', data: @post } else render json: { status: 'SUCCESS', message: 'Not updated', data: @post.errors } end end private def set_post @post = Post.find(params[:id]) end def post_params params.require(:post).permit(:title,:content) end end end end 初期データ作成 今回はseedで作ってみます。 seedの書き方はこの記事の参考しています→railsのseedの書き方いろいろ config/db/seeds 15.times do |i| Post.create!( title: "title#{i+1}", content: "テキスト#{i+1}" * 10 ) end seed書いたら $ docker-compose run web rails db:seed エラーが出ないので、無事にできたようです。 postmanを使用して動作の確認 データはseedで生成したので Railsのサーバーを動かしてみます。 $ docker-compose up 次はPostmanを開きます。 GET まずはGETの方にhttp://localhost:3000/api/v1/posts 、もしくは http://0.0.0.0:3000/api/v1/posts と記述していきます。 下の方にidの1〜15番のデータを取得することができました。 今度はidを指定します。 POST 次はデータ作成してみましょう。 JSONのデータ形式で渡します。 Sendするとちゃんとid16が表示されました。 PUT 今回はURLをidを16に指定します http://0.0.0.0:3000/api/v1/posts/16 登録したデータをupdate更新してみます。 PUTの選択とJSON形式の設定を忘れないように DELETE 最後に削除(Destroy)してみます。 同じURLをidを16に指定します http://0.0.0.0:3000/api/v1/posts/16 DELETEの選択で実行すれば、 無事に削除できたようですね まとめ 以上、Dockerの環境構築+RailsのAPIモードのまとめでした。 今回Rspecのテストは書かないのですが、 こちらの記事:【Rails】APIテストの書き方がありますので、興味がある方はご参考ください もし内容の誤りがありましたら、ご指摘いただければ幸いです。 最後まで読んでいただき、ありがとうございました。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

DockerでLaravelの開発環境

ディレクトリは以下のような構成。 docker-compose-laravel/ ├ docker ┬ php ─ Dockerfile │ └ web ─ default.conf ├ docker-compose.yml ├ laravel-project webコンテナ、dbコンテナ、appコンテナの3つを立ち上げる。 appコンテナのイメージはDockerfileより作成。 docker-compose.yml version: '3' services: web: image: nginx:1.15.6 ports: - '8000:80' #ホスト:コンテナ depends_on: - app #appコンテナ起動後に立ち上げる volumes: - ./docker/web/default.conf:/etc/nginx/conf.d/default.conf #ホストディレクトリ:コンテナディレクトリ - .:/var/www/html app: build: ./docker/php volumes: - .:/var/www/html depends_on: - mysql mysql: image: mysql:5.7 environment: #DBの基本設定 MYSQL_DATABASE: sample MYSQL_USER: user MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: password ports: - "3306:3306" volumes: - mysql-data:/var/lib/mysql volumes: mysql-data: #mysql-dataというディレクトリを作成 Dockerfile FROM php:7.2-fpm # コンポーザーをインストール RUN cd /usr/bin && curl -s http://getcomposer.org/installer | php && ln -s /usr/bin/composer.phar /usr/bin/composer RUN apt-get update \ && apt-get install -y \ git \ zip \ unzip \ vim RUN apt-get update \ && apt-get install -y libpq-dev \ && docker-php-ext-install pdo_mysql pdo_pgsql WORKDIR /var/www/html laravelの基本設定。おそらくDockerfileに下記を記載しても大丈夫なはず。 terminal lnoueryo@DESKTOP:~/$ composer create-project --prefer-dist laravel/laravel lnoueryo@DESKTOP:~/$ my-laravel-app lnoueryo@DESKTOP:~/$ cd my-laravel-app lnoueryo@DESKTOP:~/$ php artisan migrate .env DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=sample DB_USERNAME=user DB_PASSWORD=password nginxの設定。 default.conf server { listen 80; root /var/www/html/my-laravel-app/public; #publicを読む index index.php index.html index.htm; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { #phpを読み込ませる fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } さぁ立ち上げよう。 docker-compose up -d VScodeで書く際に権限の問題が発生するため都度下記のコマンドを使う。 terminal chown www-data storage/ -R chmod -R 777 hoge/ #rootじゃない人はsudoコマンドね こちらのサイトを参考にさせて頂きました。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Dockerコンテナ起動時に環境変数をquarkusのapplication.propertiesに渡す方法

はじめに quarkusでは以下のようにapplication.propertiesに設定した値を変数に代入することができます。 https://quarkus.io/guides/config 開発環境、ステージング環境、本番環境など異なる環境によって変数の値が異なる場合以下のように記載することもできますが、 ビルドした成果物を管理する際は環境ごとに管理しなければいけません。 application.properties quarkus.http.port=9090 %dev.quarkus.http.port=8181 %staging.quarkus.http.port=9999 ちょうど業務で成果物をDockerイメージで管理することがあり、環境ごとに成果物が異なるのは管理の面で嫌だなぁと思っておりました。 そこで本記事では、環境によって変数の値が異なる場合でも、管理するDockerイメージを一つで済ませる方法を記載します。 ※サンプルのプロジェクトを修正し説明します 準備 以下のコマンドでサンプルプロジェクトを作成します。 $ mvn io.quarkus:quarkus-maven-plugin:1.13.2.Final:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=config-quickstart \ -DclassName="org.acme.config.GreetingResource" \ -Dpath="/greeting" $ cd config-quickstart ディレクトリ構造は以下のようになっていると思います。 . ├── mvnw ├── mvnw.cmd ├── pom.xml ├── README.md └── src ├── main │   ├── docker │   │   ├── Dockerfile.jvm │   │   ├── Dockerfile.legacy-jar │   │   ├── Dockerfile.native │   │   └── Dockerfile.native-distroless │   ├── java │   │   └── org │   │   └── acme │   │   └── config │   │   └── GreetingResource.java │   └── resources │   ├── application.properties │   └── META-INF │   └── resources │   └── index.html └── test └── java └── org └── acme └── config ├── GreetingResourceTest.java └── NativeGreetingResourceIT.java application.properties修正 現段階では何も記載されていないので、以下を記載します。 src/main/resources/application.properties greeting.message = hello greeting.name = ${NAME:quarkus} # ${環境変数名:デフォルト値} ソース修正 以下のように修正します src/main/java/org/acme/config/GreetingResource.java package org.acme.config; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.eclipse.microprofile.config.inject.ConfigProperty; //★追加 @Path("/greeting") public class GreetingResource { @ConfigProperty(name = "greeting.message") //★追加 String message; //★追加 @ConfigProperty(name = "greeting.name") //★追加 String name; //★追加 @GET @Produces(MediaType.TEXT_PLAIN) public String hello() { return message + " " + name; //★修正 } } 修正したソースコードをbuild 以下のコマンドを実行するとquarkus-run.jarというファイルが作成されます。(testはskipしてます) $ mvn package -Pnative -Dnative-image.docker-build=true -Dmaven.test.skip=true $ ls target/quarkus-app/ app lib quarkus quarkus-app-dependencies.txt quarkus-run.jar Dockerコンテナイメージ作成 以下のコマンドでDockerのコンテナイメージを作成します。 $ docker build -f src/main/docker/Dockerfile.jvm -t quarkus/greeting $ docker image ls | grep greeting quarkus/greeting latest 10466a00a3a4 2 hours ago 330MB 作成されてますね。 環境変数を設定して作成したイメージを起動 docker-composeを使用し、イメージを起動したいと思います。 以下のyamlを作成し、application.propertiesに記載した環境変数を設定します。 docker-compose.yaml version: '3.3' services: quarkus-greeting: image: quarkus/greeting:latest container_name: quarkus-greeting environment: - NAME=docker ports: - 8080:8080 以下のコマンドでイメージを起動し、起動確認します。 $ docker-compose up -d $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9a93d018db6e quarkus/greeting:latest "/deployments/run-ja…" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp quarkus-greeting 念のため環境変数が設定されているか確認 $ docker exec -it 9a93d018db6e env | grep NAME=docker NAME=docker アプリケーションの動作確認 curlコマンドで起動したイメージに対してリクエストを投げてみます $ curl localhost:8080/greeting hello docker 意図した値が入ってますね。 ちなみに、 環境変数を設定しない場合はapplication.propertiesで設定したデフォルト値が使用され、以下のような結果になります。 $ curl localhost:8080/greeting hello quarkus このように、環境ごとに変数の値が異なる場合でもイメージは1つで済みそうですね。 今回はdocker-composeでしたがkubernetesの場合でもmanifestfileに環境変数を設定することで同様のことができます。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Vue+Flask on DockerのWebアプリケーションをAzureにデプロイする

はじめに とあるシステムのプロトタイプを作成した時のメモとなります。Vue+Flaskで構成されたDocker環境で動くSPAのアプリを作成し、WebアプリケーションをAzure App Serviceとしてデプロイしました。特にAzure関係の参考記事が少なく苦労したので紹介したいと思います。また、自分はM1のMacを使用していてDockerがpreview版だったのでそこでも躓きました笑(※今は正式版がでました) 環境 Mac OS : 11.1 docker desktop : 3.3.1 yarn : 1.10.1 node : v10.13.0 python : 3.6.13 ローカルにデプロイ まずVue+Flaskのアプリケーションをローカルで実装します。 参考記事の記事を参考にさせていただきました。 サンプルプログラムはここにあげました。 主なファイルの構成は以下の通りです(一部省略)。 Vue_Flask_App_Template/ ┝ backend/ ┝ app.py ┝ Dockerfile └ requirements.txt ┝ frontend/ ┝ src/ └ main.js ┝ util ┝ Dockerfile └ vue.config.js ┝ docker-compose.yml フロントエンドのvueコンテナとバックエンドのFlaskをそれぞれ作成しています。 ローカルではdocker-composeを使ってデプロイしました。 docker-compose.yml version: '3' services: vue: build: ./frontend ports: - "8080:8080" volumes: - .:/shared working_dir: /shared/frontend stdin_open: true tty: true depends_on: - flask command: yarn run serve flask: build: ./backend ports: - "5000:5000" volumes: - .:/shared working_dir: /shared/backend environment: FLASK_DEBUG: 1 FLASK_APP: ./app.py tty: true command: python app.py 以下のコマンドでデプロイします。 docker-compose run vue yarn docker-compose build docker-compose up vue デプロイが成功すると簡単ですが以下のようなWebアプリケーションができます。 簡単なアプリケーションですが、backend側で作成したランダムな数をフロントエンド側で描写するというものが完成しました。 Azureにデプロイ 課題にも書きますが、複数コンテナーが現在プレビュー段階のため試行錯誤しましたがうまくいきませんでした。そのため、今回はbackend側とfrontend側で二つのWebアプリケーションを作成し通信するという方法を取りました。 Dockerfile作成 frontend側とbackend側のDockerfileはそれぞれ以下の通りです。 # backend/Dockerfile FROM python:3.6 WORKDIR /app ADD . /app RUN pip install --trusted-host pypi.python.org -r requirements.txt EXPOSE 80 CMD ["python", "app.py"] # frontend/Dockerfile FROM node:10.13.0 WORKDIR /frontend COPY . /frontend RUN yarn install EXPOSE 80 CMD ["yarn", "run", "serve"] Portの変更 Azure App Serviceではカスタムコンテナーがポート80で立ち上がるのを前提としているため、backendとfrontendのポートをどちらも80に設定し直します。具体的には、app.py内のport、vue.config.js内のportを現状のものから変更します。 backend/app.py if __name__ == '__main__': app.run(host='0.0.0.0', port=80, debug=True) frontend/vue.config.js module.exports = { assetsDir: 'static', devServer: { port: 80, host: '0.0.0.0', disableHostCheck: true, }, }; イメージのビルドと格納を行う 公式のドキュメントを参考に、Azure Container Registryを使用してイメージのビルドと格納を行います。 まずAzureのポータルでAzure Container Registryをよしなに作成します。 その後、backendのディレクトリに入り、次のコマンドを実行します。container_registry_nameはレジストリの[ログインサーバー]から取得できます。 このコマンドにより、フォルダーの内容がAzure Container Registryに送信され、Dockerファイルの手順に従ってイメージがビルドされ格納されるらしいです。 az acr build --registry <container_registry_name> --image <image_name> . frontend側も同様ですが、APIのURLにbackendで出来上がったURLを指定しなくてはいけないため、後ほど行います。 Webアプリを作成してデプロイ 同じく公式のドキュメントを参考にします。 Azureのポータルから [リソースの作成]>[Webアプリ]>[作成] でWebアプリを作成します。 設定の一部を記載します。 公開:Dockerコンテナー オプション:単一コンテナー イメージソース:Azure Container Registry レジストリ:container_registry_name(先ほど作成したレジストリ) イメージ:image_name(先ほど作成したイメージ) 最後に[確認と作成]を選択し、[作成]します。Webアプリがデプロイするまでしばらくかかります。 できたら[参照]からデプロイされているのを確認します。 frontend側のデプロイ まず、先ほどはAPI通信にlocalhostのURLをしていしていたので変更します。 ~~~の部分には先ほど作成したbackendのURLを指定します。 frontend/const/util.py export const API_BASE_URI= "<~~~.azurewebsites.net>" 後は同様の手順でfrontend側のWebアプリケーションも作成します。 frontendのディレクトリに移動し、以下のコマンドを叩きレジストリに格納後、Azure App Serviceでデプロイします。 az acr build --registry <container_registry_name> --image <image_name> . 完成! 躓いたポイント 兎に角ポートの設定がめんどうでした。ポート番号を80以外で設定してしまうと簡単にはいかないみたいです。 また、以前使っていたdocker pushを使用する方法(参考)がプレビュー版を使っているせいか使えなくなっていたため、今回別の手段を使用しました。 課題 複数コンテナー(docker-compose)でデプロイできなかったのが今回の課題です。二つのWebアプリケーション間で通信を行なっているため、規模が大きくなるとどうしても重くなってしまいます。 NginxコンテナーやWeb App for Containersを使えばうまくできそうなので次は試してみようと思います。ご存知の方は教えていただければ幸いです。 最後に 今回は、VueとFlaskで作ったDockerのアプリケーションをAzureでデプロイをしました。 公式のドキュメンテーションも充実していますが、抽象的だったり、カスタムに対応していなかったりして苦労しました。 少しでも参考になれば幸いです。 手探りで行っていたため、足りないところがあると思います。間違っている点などがあれば教えていただければと思います。 参考記事 ローカルを汚さずdockerを使ってvue.jsの開発環境を作る[vuecli4] Vue.jsとFlaskのDocker環境を構築してみた Vue.js+Flaskで画像のアップロード機能
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Go RestAPI のあれこれ ついでにDockerも

今回できたこと Goを使用してREST APIを作成した。 その際,Dockerを使用し,フレームワークには軽量なechoを使用した。 また,SSL化も行い,Let`s Encriptを使用した。 最初に知っておきたいコマンド (全削除) (注意)$ docker rm -f `docker ps -a -q` (build) $ docker-compose up -d --build (コンテナ起動) $ docker-compose exec golang bash (動いているdocker一覧表示) $ docker-compose ps (作成した全てのdocker一覧表示) $ docker-compose ps -a (コンテナ内に入る) $ docker-compose exec golang bash $ docker-compose exec mysql bash (MySQL接続) root@コンテナ番号:/# mysql -u root -p -h 127.0.0.1 mysql> show databases; mysql> use golang; mysql> show tables; mysql> SELECT * FROM `users`; 全容 初期設定 docker, docker-compose インストール済み Docker のインストール手順 Docker Compose のインストール フォルダは以下を作る └─プロジェクト名 ├─server │ ├─docker │ │ ├─golang │ │ │ └─Dockerfile │ │ ├─mysql │ │ │ ├─Dockerfile │ │ │ └─db │ │ │ └─init.sql │ │ ├─src │ │ │ ├─crt <-Dockerで自動生成(証明書が入る予定) │ │ │ ├─databases │ │ │ │ └─main.go │ │ │ ├─routing │ │ │ │ └─main.go │ │ │ ├─go.mod <-自動生成 │ │ │ ├─go.sum <-自動生成 │ │ │ └─main.go │ │ ├─docker-compose.yml │ │ └─api_v1.yaml <-必要に応じて │ └─Server.md <-必要に応じて └─README.md <-必要に応じて 証明書作成 無料の認証局を利用する Let`s Encrypt certbot 証明書が生成されているか確認する $ ls /etc/letsencrypt/live/<自分のドメイン名> >> README cert.pem chain.pem fullchain.pem privkey.pem プロジェクトを書き込み DockerComposeの設定 docker-compose.yml version: "3" services: golang: build: ./golang/ image: image_golang container_name: container_api volumes: - ./src:/go/src # 証明書を/go/src/crtへ - /etc/letsencrypt:/go/src/crt ports: - "443:443" tty: true mysql: # platform: linux/x86_64 #AppleSiliconを使用時,必要 build: ./mysql/ image: image_mysql container_name: container_db volumes: - ./mysql/db:/docker-entrypoint-initdb.d #初期データをマウントする場所 environment: # コンテナ内のMySQLを起動する際のパスワードを設定 - MYSQL_DATABASE=golang # 作成するデータベース名 - MYSQL_USER=akidon # 作業ユーザー名(任意の値) - MYSQL_PASSWORD=12345 # 作業ユーザーのパスワード(任意の値) - MYSQL_ROOT_PASSWORD=root # rootユーザーのパスワード(デフォルトでは「root」) ports: - "3306:3306" tty: true 説明 versionは3系が最新版で、versionによって書き方が異なる build: Dockerfileが存在する場所 image: イメージの名前 container_name: コンテナの名前 volumes: 「./a:/b」 aはホスト側のフォルダを bのdockerコンテナ側へ ports: ポート environment: 環境変数 tty: true コンテナ起動永続化 links: 他のコンテナの接続? AppleSiliconを使用している場合は17行目のリマークを外す DockerFileの設定 golang/Dockerfile. # golang/Dockerfile FROM golang:1.14 WORKDIR /go/src mysql/Dockerfile. # mysql/Dockerfile FROM mysql MySQLの初期設定 init.sql -- MySQL dump 10.13 Distrib 5.1.51, for pc-linux-gnu (i686) -- -- Host: 127.0.0.1 Database: world -- ------------------------------------------------------ -- Server version 5.1.51-debug-log /*以下Databaseの内容が記載される*/ DROP SCHEMA IF EXISTS golang; CREATE SCHEMA golang; USE golang; DROP TABLE IF EXISTS golang; CREATE TABLE users ( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, name VARCHAR(40), age INT(10), created_at TIMESTAMP DEFAULT NULL, updated_at TIMESTAMP DEFAULT NULL, deleted_at TIMESTAMP DEFAULT NULL ); INSERT INTO users (id, name, age) VALUES (1, "testKun", 21); 説明 created_at updated_at deleted_at はGormを使用する際,追加,更新,削除で必要になる要素 Goの設定 databases/main.go package databases import ( "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) // SQLConnect DB接続 func GormConnect() (database *gorm.DB) { DBMS := "mysql" // MySQL PROTOCOL := "tcp(container_db)" // MySQLコンテナ名 DBNAME := "golang" // テーブル名 USER := "akidon" // MySQLユーザー名 PASS := "12345" // パスワード CONNECT := USER + ":" + PASS + "@" +PROTOCOL + "/" + DBNAME + "?charset=utf8&parseTime=True&loc=Local" // 修正!! db, err := gorm.Open(DBMS, CONNECT) if err != nil { panic(err.Error()) } else { fmt.Println("DB接続成功") } return db } 説明 PROTOCOL := "tcp(container_db)" // MySQLコンテナ名 のcontainer_dbはDockerComposeのcontainer_name:によるもの 間違っていれば接続できない routing/main.go package routing import ( "fmt" "github.com/labstack/echo" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" "src/databases" ) type User struct { gorm.Model Name string `json:"name"` Age int `json:"age"` } func (u User) String() string { return fmt.Sprintf("Name:%s \n Age:%d \n ", u.Name, u.Age) } // ユーザー情報取得 func BaseAPI_GET() echo.HandlerFunc { return func(c echo.Context) error { db := databases.GormConnect() defer db.Close() text1 := search(db) return c.JSON(200, text1) } } // ユーザーを登録,更新 func BaseAPI_POST() echo.HandlerFunc { return func(c echo.Context) error { db := databases.GormConnect() defer db.Close() //追加・更新 user := new(User) if err := c.Bind(user); err != nil { return err } user1 := User{ Name: user.Name, Age: user.Age, } insertUsers := []User{user1} insert(insertUsers, db) // update(user1, db) return c.JSON(200, "追加完了") } } func insert(users []User, db *gorm.DB) { for _, user := range users { db.NewRecord(user) db.Create(&user) } } func update(users User, db *gorm.DB) { var user User db.Model(&user).Where("id = ?", 1).Update(map[string]interface{}{"name": users.Name, "age": users.Age}) } func search(db *gorm.DB) []User { var user []User // 同じ位置にいるリストを取得 db.Raw("SELECT * FROM users").Scan(&user) return user } 説明 routing/main.go type User struct { gorm.Model Name string `json:"name"` Age int `json:"age"` } User(単数形)はMySQLのテーブル名「Users(複数形)」単数名にする必要がある Name,Ageは先頭大文字である必要がある。 json:"name"はリクエストボディに関連させる名前。 main.go package main import ( "github.com/labstack/echo" "src/routing" ) func main() { e := echo.New() // routing e.GET("/user",routing.BaseAPI_GET()) e.POST("/user",routing.BaseAPI_POST()) e.Logger.Fatal(e.StartTLS(":443", "/crt/live/<あなたのドメイン名>/fullchain.pem", "/crt/live/<あなたのドメイン名>/privkey.pem")) } HTTPでよいなら docker-compose.yml version: "3" services: golang: build: ./golang/ image: image_golang container_name: container_api volumes: - ./src:/go/src # 証明書を/go/src/crtへ # - /etc/letsencrypt:/go/src/crt <- 削除 ports: # - "443:443" <- 削除 - "8080:8080" <- 追加 tty: true mysql: # platform: linux/x86_64 #AppleSiliconを使用時,必要 build: ./mysql/ image: image_mysql container_name: container_db volumes: - ./mysql/db:/docker-entrypoint-initdb.d #初期データをマウントする場所 environment: # コンテナ内のMySQLを起動する際のパスワードを設定 - MYSQL_DATABASE=golang # 作成するデータベース名 - MYSQL_USER=akidon # 作業ユーザー名(任意の値) - MYSQL_PASSWORD=12345 # 作業ユーザーのパスワード(任意の値) - MYSQL_ROOT_PASSWORD=root # rootユーザーのパスワード(デフォルトでは「root」) ports: - "3306:3306" tty: true main.go // e.Logger.Fatal(e.StartTLS(":443", "/crt/live/<あなたのドメイン名>/fullchain.pem", "/crt/live/<あなたのドメイン名>/privkey.pem")) e.Logger.Fatal(e.Start(":8080")) // <- 追加 オレオレ証明書では crtに ・ myself.csr ・ myself.key ・ myself.crt がある場合 main.go // e.Logger.Fatal(e.StartTLS(":443", "./crt/live/<あなたのドメイン名>/fullchain.pem", "./crt/live/<あなたのドメイン名>/privkey.pem")) e.Logger.Fatal(e.StartTLS(":443", "crt/myself.crt", "crt/myself.key")) // <- 追加 動かす $ cd ../プロジェクト名/server/docker (再ビルドしても変更されない場合はキャッシュが残っている可能性がある為,全削除) (注意) $ docker rm -f `docker ps -a -q` (ビルドする) $ docker compose up -d --build (コンテナ内に入る)**1分ぐらい待つ(MySQLの初期設定の完了に時間がかかる)** $ docker-compose exec mysql bash root@コンテナ番号:# exit $ docker-compose exec golang bash (go mod init フォルダ名) root@コンテナ番号:/go/src# go mod init src root@コンテナ番号:/go/src# go run main.go MySQLの中を覗く % docker-compose exec mysql bash root@コンテナ番号:/# mysql -u root -p -h 127.0.0.1 (パスワードの入力を求められるので「root」を入力) -> root (現在存在するアカウントの確認) (hostに「%」がついてるか確認) mysql> select host,user from mysql.user; +-----------+------------------+ | host | user | +-----------+------------------+ | % | akidon | | % | root | | localhost | mysql.infoschema | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +-----------+------------------+ (ついていない場合は以下コードで追加できたはず) mysql> grant all privileges on golang.* to 'akidon'@'%'; mysql> show databases; +--------------------+ | Database | +--------------------+ | golang | <- 作成できてるか確認 | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.06 sec) mysql> use golang; mysql> show tables; +------------------+ | Tables_in_golang | +------------------+ | users | <- 作成できてるか確認 +------------------+ 1 row in set (0.01 sec) mysql> SELECT * FROM `users`; +----+---------+------+------------+------------+------------+ | id | name | age | created_at | updated_at | deleted_at | +----+---------+------+------------+------------+------------+ | 1 | testKun | 21 | NULL | NULL | NULL | +----+---------+------+------------+------------+------------+ 1 row in set (0.00 sec) この時点でエラーが起きた場合 ・src/main.go 27行目のcontainer_dbはdocker-composeで指定したコンテナ名を指定しているか。 ・ポート解放してるか ・データベース(テーブル)が正しく作成されているか(今回ならgolang) ・大文字小文字の区別を無視していないか ・go mod init src したか?(この辺は理解不足で間違っている場合がある。src以下のファイルをサブパッケージとして参照できるようにする??) ・docker起動できているか以下コマンドで確認 # 動いているdocker一覧表示 docker-compose ps # 作成した全てのdocker一覧表示 docker-compose ps -a 豆知識 main.goの内容を変更してもDocker再buildする必要はない SequelAce GoENV GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/go/src/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build147035606=/tmp/go-build -gno-record-gcc-switches" 参考記事 docker-compose upって何? Go言語の依存モジュール管理ツール Modules の使い方 他多数
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Dockerコンテナ上でGreengrass(V1)を実行する

はじめに AWSはGreengrass Coreソフトウェアと依存関係がインストールされたDocker file、Dockerイメージを公開しています。 今回は、以下の公式ドキュメントを参考に、EC2上のDockerコンテナでGreengrassを実行します。 参考:Docker コンテナでの AWS IoT Greengrass の実行 1 環境構築 公式ドキュメントの「Prerequisites」を参考に、Greengrassを実行する環境を用意します。 今回は最終的に以下の構成となります。 1-1 ネットワーク設定 VPC周辺を以下の通り作成します。 なお、作業は東京リージョンで行い、サブネットはap-northeast-1aに作成しています。 ※詳細な手順は以下を参照のこと  参考:AWS上にエッジ環境を構築してGreengrass(V1)の動きを確認する - 1-1 ネットワーク周りの作成 作成するもの 詳細 VPC CIDR:10.0.0.0/16 サブネット CIDR:10.0.0.0/24 インターネットゲートウェイ VPCにアタッチする ルートテーブル 10.0.0.0/16 -> local , 0.0.0.0/0 -> IGW 1-2 インスタンスの作成 次に、今回Greengrassを動かすEC2インスタンスを作成します。 ※詳細な手順は以下を参照のこと  参考:AWS上にエッジ環境を構築してGreengrass(V1)の動きを確認する - 1-2 EC2インスタンスの作成 1.以下の通りセキュリティグループを作成する ※アウトバウンドルールはデフォルトのままとしている タイプ ポート範囲 ソース 備考 SSH 22 マイIP 自身の環境からEC2にSSH接続できるようにするため カスタムTCP 8883 任意の場所 IoT Coreとの通信用 2.インスタンスを以下の通り作成する 設定項目 選択した内容 AMI Amazon Linux 2 AMI(64ビット(x86)) インスタンスタイプ t2.micro ネットワーク ※作成したVPC サブネット ※作成したサブネット 自動割り当てパブリックIP 有効 セキュリティグループ ※作成したセキュリティグループ 3.yum upgrade と yum update を実施する $ sudo yum upgrade -y $ sudo yum update -y 4.タイムゾーンを変更する 参考:【Linux】タイムゾーン(Timezone)の変更 #タイムゾーンファイルの変更 $ sudo ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime #タイムゾーンが変更されていることを確認 $ date Wed Apr 14 18:29:31 JST 2021 #再起動後にUTCに戻ることを防ぐため /etc/sysconfig/clock を編集 $ sudo vim /etc/sysconfig/clock /etc/sysconfig/clock ZONE="Asia/Tokyo" UTC=false 1-3 DockerとAWS CLIのインストール 公式ドキュメントのPrerequisitesにある通り、DockerとAWS CLIをインストールします。 「AWS CLI version 2」タブの要件に従います。 1.Dockerをインストールする 参考:Amazon Linux2にDockerをインストールする #Dockerインストール $ sudo yum install -y docker #ec2-userをdockerグループに追加(コマンド実行後ログインし直す) $ sudo usermod -a -G docker ec2-user #バージョン確認 $ docker version Client: Version: 20.10.4 #中略 Server: Engine: Version: 20.10.4 #後略 #自動起動設定 $ sudo systemctl enable docker 2.AWS CLIをバージョン2にアップデートする 参考:Linux で AWS CLI バージョン 2 をインストールする #現在のバージョン確認 $ aws --version aws-cli/1.18.147 Python/2.7.18 Linux/4.14.225-169.362.amzn2.x86_64 botocore/1.18.6 #AWS CLI V1の削除 $ which aws /usr/bin/aws #AWS CLI V2のインストール $ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install You can now run: /usr/local/bin/aws --version #インストールされたことの確認 $ aws --version aws-cli/2.1.38 Python/3.8.8 Linux/4.14.225-169.362.amzn2.x86_64 exe/x86_64.amzn.2 prompt/off 以上で以下の構成まで作成できました。 2 Amazon ECRからGreengrassコンテナイメージを取得する 公式ドキュメントに記載の通り、Greengrassのコンテナイメージを取得します。 参考:ステップ 1. Amazon ECR から AWS IoT Greengrass コンテナイメージを取得する 1.awsコマンドを実行するため、ユーザのクレデンシャル情報環境変数に設定する ※あるいはaws configureコマンドで設定を行う  なお、利用するIAMユーザには ecr:GetAuthorizationToken のポリシーがアタッチされている必要がある #環境変数の設定 $ export AWS_ACCESS_KEY_ID='AWSのアクセスキー' $ export AWS_SECRET_ACCESS_KEY='AWSのシークレットアクセスキー' #設定されていることの確認 $ echo $AWS_ACCESS_KEY_ID $ echo $AWS_SECRET_ACCESS_KEY 2.Greengrassのコンテナイメージをプルする #Amazon ECRレジストリにログイン $ aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin https://216483018798.dkr.ecr.us-west-2.amazonaws.com WARNING! Your password will be stored unencrypted in /home/ec2-user/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded #Greengrassコンテナイメージを取得 $ docker pull 216483018798.dkr.ecr.us-west-2.amazonaws.com/aws-iot-greengrass:latest #取得結果 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE 216483018798.dkr.ecr.us-west-2.amazonaws.com/aws-iot-greengrass latest d32ac0324f03 8 weeks ago 1.25GB 3.シンボリックリンクとハードリンクの保護を有効にする #rootユーザに切り替え(sudoで実行してもPermission Deniedになったため) $ sudo su - #/etc/sysctl.confに設定を追加 $ echo '# AWS Greengrass' >> /etc/sysctl.conf $ echo 'fs.protected_hardlinks = 1' >> /etc/sysctl.conf $ echo 'fs.protected_symlinks = 1' >> /etc/sysctl.conf 4.IPv4 ネットワーク転送を有効にする #ファイル末尾に「net.ipv4.ip_forward = 1」を追記 vim /etc/sysctl.conf #設定の反映 $ sysctl -p fs.protected_hardlinks = 1 fs.protected_symlinks = 1 net.ipv4.ip_forward = 1 3 GreengrassグループとCoreの作成 IoT CoreのマネジメントコンソールでGreengrassグループを作成します。 作成後、証明書とコアの設定ファイルを取得します。 参考:AWS IoT Greengrass の AWS IoT の設定 1.IoT Coreのマネジメントコンソールで Greengrass > クラシック(V1) > 「グループの作成」の順にクリック 2.「デフォルト作成を使用」をクリック 3.任意のグループ名を入力して「次へ」をクリック 4.任意のCoreの名前を入力して「次へ」をクリック 5.「グループとCoreの作成」をクリック 6.「これらのリソースはtar.gzとしてダウンロードしてください」をクリックしてセキュリティリソースを取得したら、「完了」をクリック ※ルートCAの取得はのちの手順で行う ※Greengrass CoreのソフトウェアはDockerイメージとして取得済なのでここでは不要 4 Greengrassをローカルで実行 セキュリティリソースをEC2インスタンスにアップロードし、Greengrass Coreを起動します。 1.先ほどダウンロードしたtar.gzファイルをEC2インスタンスにアップロードする ※今回はFileZillaを利用した 2.tar.gzファイルを解凍し、greengrass用のディレクトリに格納する #格納先のディレクトリを作成 $pwd /home/ec2-user $ mkdir greengrass #解凍する $ tar xzvf xxxxxxxxxx.tar.gz -C greengrass/ certs/xxxxxxxxxx.cert.pem certs/xxxxxxxxxx.private.key certs/xxxxxxxxxx.public.key config/config.json $ ls greengrass/ certs config 3.AmazonのルートCA証明書を取得する #モノの証明書、秘密鍵が格納されているディレクトリに移動 $ cd greengrass/certs/ #ルートCA証明書を取得 $ sudo wget -O root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem $ ls root.ca.pem root.ca.pem 4.IoT Greengrassコンテナをを実行する #certs、configディレクトリをバインド、8883のフォワーディングなどを行い実行 $ docker run --rm --init -it --name aws-iot-greengrass \ --entrypoint /greengrass-entrypoint.sh \ -v '証明書を格納したディレクトリのパス':/greengrass/certs \ -v 'configファイルを格納したディレクトリのパス':/greengrass/config \ -p 8883:8883 \ 216483018798.dkr.ecr.us-west-2.amazonaws.com/aws-iot-greengrass:latest #成功すると以下の通り出力される grep: /greengrass/ggc/deployment/group/group.json: No such file or directory Setting up greengrass daemon Validating hardlink/softlink protection Waiting for up to 1m10s for Daemon to start Greengrass successfully started with PID: 12 5 検証用の各種設定 今回は、最終的にGreengrassデバイスからのMQTTメッセージで実行するLambdaを用意し、動作することを確認します。 これを検証するための準備を行います。 5-1 グループのLambda設定 公式ドキュメントの以下の引用の通り、GreengrassをDocker上で実行する場合は、Lambdaを「コンテナなし」で実行する必要があります。 対象グループのLambdaのデフォルト設定を先に変えておきます。 Docker コンテナで AWS IoT Greengrass で実行する場合、すべての Lambda 関数はコンテナ化を使用しないで実行する必要があります。このステップでは、グループのデフォルトのコンテナ化を [No container (コンテナなし)] に設定します。グループを初めてデプロイする前に行う必要があります。 引用元:ステップ 4. Greengrassグループに対して「コンテナなし」コンテナ化を構成する 1.IoT Coreのマネジメントコンソールで Greengrass > クラシック(V1) > グループ の順にクリック 2.対象のグループ名 > 設定 の順にクリック 3.「Lambda ランタイム環境」でデフォルトの Lambda 関数コンテナ化で「コンテナなし」を選択し、「デフォルトのLambda実行設定を更新する」をクリック 4.「続行」をクリック 5-2 Lambdaの作成 MQTTメッセージを受け取ったあとに以下の挙動をするLambdaを作成します。 ローカルのログファイルに書き込む IoT CoreにMQTTメッセージを送る 1.ローカルで以下のプログラムを作成する docker_test.py import greengrasssdk import logging import sys import json import datetime logger = logging.getLogger(__name__) logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) client = greengrasssdk.client("iot-data") logfile = "/tmp/docker_test.log" def docker_test(event, context): date = datetime.datetime.now() timestamp = date.strftime("%Y-%m-%d %H:%M:%S") client.publish( topic="test/dockertest", payload=json.dumps( { "function": "docker_test", "message": "This is Test", "version": "1.0", "timestamp": timestamp } ) ) f = open(logfile, mode="a") f.write(timestamp + " success!\n") f.close() 2.以下で「AWS IoT Greengrass SDK for Python」をダウンロードし、「greengrasssdk」フォルダと先ほど作成したプログラムをまとめてzipファイルとして圧縮する GitHub:aws-iot-devise-sdk-for-python 3.Lambdaのマネジメントコンソール画面で 関数 > 「関数の作成」の順にクリック 4.以下の通り設定して「関数の作成」をクリック 一から作成 関数名:※任意の関数名を設定 ランタイム:Python3.7 5.アップロード元 > .zipファイル > アップロード > 先ほど作成したzipファイルを選択し、「保存」をクリックする 6.ランタイム設定の「編集」をクリックし、ハンドラを「[ファイル名].[関数名]」にして「保存」をクリック ※上記プログラムのファイル名を「docker_test.py」としていた場合は「docker_test.docker_test」となる 7.アクション > 新しいバージョンを発行 > 「発行」の順にクリック 8.エイリアスタブ > 「エイリアスを作成」の順にクリックして、任意のエイリアス名を入力し、先ほど発行したバージョンを選択して「保存」をクリック 5-3 Greengrassデバイスの用意 Docker上で動くGreengrass Coreと通信するGreengrassデバイスを用意します。 今回はこちらもEC2を利用して仮想デバイスという形で用意します。 1.IoT Coreのマネジメントコンソールで Greengrass > クラシック(V1) > グループ の順にクリック 2.対象のグループ名 > デバイス > 「デバイスの追加」の順にクリック 3.「新しいデバイスの作成」をクリック 4.任意のモノの名前を入力して「次へ」をクリック 5.1-Clickデプロイの「デフォルトを使用」をクリック 6.「これらのリソースはtar.gzとしてダウンロードしてください」をクリックしてファイルをダウンロードし、「完了」をクリック 7.Greengrassデバイス用に「1-2 インスタンスの作成」と同じ設定でEC2インスタンスを用意する ※VPC、サブネット、セキュリティグループは上記で指定したものと同じものを利用 8.インスタンスが起動したらsshで接続し sudo yum upgrade と sudo yum updateを行う 9.Greengrassデバイス用のインスタンスに先ほどダウンロードしたtar.gzファイルをアップロードして解凍する ※私はFileZillaを利用した #ファイル格納用のディレクトリを作成 $ pwd /home/ec2-user $ mkdir .certs #tar.gzファイルの解凍 $ tar xzvf xxxxxxxxxx-setup.tar.gz -C .certs xxxxxxxxxx.cert.pem xxxxxxxxxx.private.key xxxxxxxxxx.public.key 10.以下のPythonプログラムを作成、実行して、グループ証明書を取得 ※/home/ec2-user/.certs はいかにgroupCA.crtとしてグループ証明書を上書きで作成 get_groupCA.py import requests import json import argparse #get args psr = argparse.ArgumentParser( description = "get groupCA" ) psr.add_argument("-t", "--things", required=True, help="thing name") psr.add_argument("-c", "--cert", required=True, help="cert file") psr.add_argument("-k", "--key", required=True, help="private key") args = psr.parse_args() things = args.things cert = args.cert key = args.key #set variables for requests url = "https://greengrass-ats.iot.ap-northeast-1.amazonaws.com:8443/greengrass/discover/thing/" + things #set path for CA file CAfile = "/home/ec2-user/.certs/groupCA.crt" #get present group CA response = requests.get(url, cert=(cert, key)) #make groupCA file jsonData = response.json() groupCA = jsonData["GGGroups"][0]['CAs'][0] f = open(CAfile, "w") f.write(groupCA) f.close() $ python --things 'モノの名前' --cert 'モノの証明書' --key '秘密鍵' 11.MQTT通信用にmosquittoをインストールする $ sudo amazon-linux-extras install epel -y $ sudo yum install mosquitto -y 5-4 Greengrassグループの設定 Lambdaの実行、各通信のためにGreengrassグループの設定を行います。 Lambdaの設定 作成したLambdaをグループに紐づけます。 1.IoT Coreのマネジメントコンソールで Greengrass > クラシック(V1) > グループ の順にクリック 2.対象のグループ名 > Lambda > 「Lambdaの追加」の順にクリック 3.「既存のLambdaを使用」 > 作成したLambdaを選択して「次へ」 > 作成したエイリアスを選択して「完了」をクリック 4.追加されたLambdaの「…」 > 設定の編集 の順にクリック 5.設定の以下項目を設定して、「更新」をクリック コンテナ化:グループのデフォルトを使用(現在:コンテナなし) Lambdaのライフサイクル:オンデマンド関数 サブスクリプション 実行したLambdaからIoT Coreへのメッセージ、IoT CoreおよびGreengrassデバイスからLambdaへのメッセージをPub/Subできるようにサブスクリプションを追加します。 1.対象のグループでサブスクリプション > 「サブスクリプションの追加」の順にクリック 2.以下のサブスクリプションを作成する ソース ターゲット トピック Lambda IoT Core test/dockertest ※Lambda内で指定したtopic IoT Core Lambda ※任意のtopic Greengrassデバイス Lambda ※任意のtopic コアの接続情報検出設定 コンテナ上のGreengrass Coreの接続情報を手動で設定します。 ※自動検出にした場合、コンテナ内のIPのみに上書きされてしまい、GreengrassデバイスからEC2インスタンスのIP宛にメッセージを送っても受け取ることができなかった 1.対象のグループで 設定 をクリック 2.Core接続情報を「接続情報の手動管理」に変更する 3.対象のグループで コア > コア名 の順にクリック 4.接続 > 編集 の順にクリック 5.接続情報を追加して「更新」をクリック エンドポイント:※Greengrassコンテナを動かしているEC2インスタンスのローカルIP ポート:8883 5-5 ログの格納先作成 Lambdaがログを書き出す先はコード上はGreengrassコンテナの/tmpとしています。 ここで書き出されたログファイルがコンテナ終了後も残るように、コンテナ上の/tmpとマッピングするローカルディレクトリを用意します。 1.Greengrassコンテナを動かすEC2インスタンスにsshで接続してディレクトリを作成する $ cd /home/ec2-user/greengrass $ mkdir tmp $ ls certs config log #コンテナ上でLambdaが書き込めるように全権を付与 $ chmod 777 log 2.Greengrassコンテナを起動中のターミナルで Ctrl + C を実行してコンテナを停止する ※これで上手くいかない場合は docker ps -a でコンテナIDを控えて、docker stop [控えたコンテナID] で停止する 3.先ほど作成したディレクトリとコンテナ上の /tmp をマッピングして再度コンテナを起動する docker run --rm --init --name aws-iot-greengrass \ --entrypoint /greengrass-entrypoint.sh \ -v /home/ec2-user/greengrass/certs:/greengrass/certs \ -v /home/ec2-user/greengrass/config:/greengrass/config \ -v /home/ec2-user/greengrass/tmp:/tmp \ -p 8883:8883 \ 216483018798.dkr.ecr.us-west-2.amazonaws.com/aws-iot-greengrass:latest 以上の手順が完了したらGreengrassグループをデプロイする。 ※AWS上で設定したグループの情報はコンテナを停止→起動するたびにデプロイが必要 デプロイによって、予定していた以下の構成となります。 6 検証 MQTTメッセージをトリガとしてコンテナ上のGreengrassがLambdaを実行できることを確認します。 6-1 IoT Core -> Lambdaで検証 IoT CoreからのMQTTメッセージをトリガとしてLambdaを実行できることを確認します。 1.IoT Coreのマネジメントコンソールで テスト をクリック 2.トピックのフィルターに「test/dockertest」と入力し、「サブスクライブ」をクリック ※Lambda内で指定しているtopic 3.トピックに公開するタブに移動し、トピック名にサブスクリプションで指定したtopicを入力し、「発行」をクリック 4.以下を確認 IoT Coreでメッセージをサブスクライブできる Greengrassコンテナを動かしているEC2のローカルにログファイルが書き出されている 6-2 Greengrassデバイス -> Lambda で検証 次にGreengrassデバイスからのMQTTメッセージでLambdaが実行されることを確認します。 この検証は、コンテナ上のGreengrassとGreengrassデバイスが通信できることの確認も含んでいます。 1.先ほどの検証で開始したIoT Coreのサブスクライブはそのままとする 2.Greengrassデバイス用のEC2に接続してMQTTをパブリッシュする mosquitto_pub --cafile 'グループ証明書' --cert 'モノの証明書' --key '秘密鍵' \ -i 'モノの名前' --tls-version tlsv1.2 \ -h 'Greengrassコンテナを動かしているEC2インスタンスのローカルIP' -p 8883 \ -q 0 -t 'サブスクリプションで指定したtopic' \ -m "{\"message\":\"Helloworld\"}" -d 3.同じく以下を確認 IoT Coreでメッセージをサブスクライブできる Greengrassコンテナを動かしているEC2のローカルにログファイルが書き出されている 7 おわりに 以上、Dockerコンテナ上で動くGreengrass(V1)の挙動を簡単に確認しました。 GreengrassデバイスからCoreへの通信がハマりどころでした。 自動検出を有効にしていたためにコンテナのローカルIPがGreengrass Coreの接続情報とされており、通信が成功しませんでした。 ※手順でも記載した通りですが、Greengrass Coreの接続情報としてEC2インスタンス自体のローカルIPを静的に指定することで解消 8 参考文献(文中で登場していないもの) Dockerコンテナ上でGreengrassを動かしている記事 GreengrassをDocker for Windows上で使用する準備とファイル読み出しテストの手順 「#2 Amazon ECRからGreengrassコンテナイメージを取得する」で実行している内容について Linux豆知識197 /etc/sysctl.conf Dockerはサービス起動時に勝手にIPフォワーディングを有効にする CentOS / RHEL 7でハードリンクおよびシンボリックリンクを保護する方法 - Centos - 2021 Docker周辺で参考にした記事 「Got permission denied while trying to connect to the Docker daemon socket」への対応 dockerでvolumeをマウントしたときのファイルのowner問題
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Dockerのコンテナ間通信のスピードを測ってみた!

...ふと思った 「Dockerコンテナ間のネットワークのスピードってどれぐらい出てるんだ??」 ...測ってみるか! ってなことで、以下の要領でDockerのコンテナが2つだけ入ったネットワークを作り、そのコンテナ間のネットワークの速度をiperfで測ってみる実験をやってみました! 実験環境 今回は、下記のようなスペックの実験環境を用意しました。 手元にあるPC intel Core i7-8750H (4.10GHz)、16GBメモリ、SSD Debian 10.9 Docker 20.10.6 AWS EC2 t2.micro (intel Xeon E5-2686 v4 2.30GHz 1vCPU、1GiBメモリ、汎用SSD) Debian 10.9 (ami-0adb6517915458bdb) Docker 20.10.6 それぞれのマシンで次のコマンドを実行し、コンテナを作成しました。 docker network create speedtest docker container run -d --network speedtest --name debian1 debian (サーバ側) docker container run -d --network speedtest --name debian2 debian (クライアント側) この後、それぞれのコンテナにアタッチし、apt install iperfを実行しました。 実験方法 クライアント側のコンテナでiperf -c [サーバ側のIPアドレス]を10秒間隔で3回実行し、平均値をとる。 そして、ホストを変えることによって CPUなどの違いで速度が変わるのか実験してみました。 結果 ・手元のPC root@ee984f974c0f:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 46796 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 51.8 GBytes 44.5 Gbits/sec root@ee984f974c0f:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 46798 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 51.6 GBytes 44.3 Gbits/sec root@ee984f974c0f:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 46800 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 52.1 GBytes 44.7 Gbits/sec 早えぇ~(心の声) / Transfer Bandwidth Max. 52.1 GB/10s 44.7 Gbit/s Min. 51.6 GB/10s 44.3 Gbit/s Avg. 51.83 GB/10s 44.5 Gbit/s めちゃくちゃ早いやん(心の声) ・AWS EC2 root@4cd0a77376b6:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 45.0 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 56282 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 27.9 GBytes 23.9 Gbits/sec root@4cd0a77376b6:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 122 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 56284 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 27.4 GBytes 23.5 Gbits/sec root@4cd0a77376b6:/# iperf -c 172.18.0.2 ------------------------------------------------------------ Client connecting to 172.18.0.2, TCP port 5001 TCP window size: 45.0 KByte (default) ------------------------------------------------------------ [ 3] local 172.18.0.3 port 56286 connected with 172.18.0.2 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 28.1 GBytes 24.2 Gbits/sec / Transfer Bandwidth Max. 28.1 GB/10s 24.2 Gbit/s Min. 27.4 GB/10s 23.5 Gbit/s Avg. 27.8 GB/10s 23.86 Gbit/s 結果総評 驚異の44Gbit/s (5.5GB/s)とか出てて正直びっくりしました。 あと、CPUなどのパーツの違いによって、コンテナ間のネットワークの速度に差が出ることもわかりました。 おもしろい実験だったと思います(自負)。 以上になります。 最後までお読みいただき、ありがとうございました!
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

"Docker needs privileged access"が無限に出てくる

現象 Dockerを一度アンインストールし、再度インストールすると、"Docker needs privileged access"というダイアログが無限に出てきて、先に進めなくなる 環境 macOS Big Sur バージョン11.2.3 原因 詳しくはわからないが、Dockerを使うとあるファイルが作成されるのだが、そのファイルが再インストールの前後で整合性が取れなくなる 解決策 うろ覚えなので正確ではないです。すみません。 $ sudo chmod o-w /Library/LaunchDaemons/* $ sudo chown root:wheel /Library/LaunchDaemons/myfile.plist $ chmod 600 XXXXX.plist 参考記事
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

M1 MacでPHP開発環境をDockerで構築する

M1チップ搭載のMacを使ってPHP開発環境をDockerで構築してみたいと思います。 やりたいこと ・ CentOS7のイメージからコンテナ作成 ・ Apache + PHPのWeb環境 ・ Macのローカルフォルダと、Dockerコンテナのフォルダ共有 ・ SSL通信ができること(httpsでアクセスできる) Docker インストール まずは「Docker Desktop for Mac」をインストールします。 こちらのページの「Mac with Apple Chip」からダウンロードできます。 https://docs.docker.com/docker-for-mac/install/ Rosetta 2も必要になるので、手順を参考にしてインストールしてください。 MacとDockerの共有フォルダ作成 Macのターミナルを起動して、Dockerコンテナと共有するフォルダを作ります。ACCOUNT_NAMEはご自身のMacアカウントと置き換えてください。 # Mac mkdir /Users/ACCOUNT_NAME/webroot Docker コンテナ作成 CeontOS 7のイメージからコンテナを作成します。ACCOUNT_NAMEはご自身のMacアカウントと置き換えてください。 # Mac docker run --privileged -it -p 80:80 -p 443:443 -v "/Users/ACCOUNT_NAME/webroot:/var/www/html" --name webserver centos:centos7 /sbin/init CentOS 時刻設定 「Docker Desktop for Mac」からコンテナのCLIボタンを押して、CentOSのコンソールを立ち上げます。 時刻を設定します。 # CentOS timedatectl set-timezone Asia/Tokyo Apache インストール Apacheをインストールします。 # CentOS yum install -y httpd Apacheを起動します。 # CentOS systemctl start httpd Macのブラウザからアクセスして、Apacheの画面が表示されればOKです。 http://localhost/ PHP インストール PHPをインストールします。標準では5.4のバージョンがインストールされるので、必要であれば他のバージョンをインストールします。 # CentOS yum install -y php インストール後はApacheを再起動します。 # CentOS systemctl restart httpd Macで作った共有フォルダにPHPの動作確認用ファイルを作成します。ACCOUNT_NAMEはご自身のMacアカウントと置き換えてください。 # Mac vi /Users/ACCOUNT_NAME/webroot/info.php 下記の内容を入力して保存します。 <?php phpinfo(); ?> PHPの動作確認用ファイルにアクセスします。 http://localhost/info.php PHPの設定が表示されればOKです。 SSL設定 httpsでアクセスできるようにcertbotをインストールします。インストールするだけで自己署名証明書が設定されます。 # CentOS yum install -y epel-release yum install -y certbot yum install -y certbot-apache インストール後はApacheを再起動します。 # CentOS systemctl restart httpd MacのSafariからhttpsでアクセスします。Chromeではキーチェーンの設定をしないとページが見れないので、Safariからアクセスします。 https://localhost/ 警告が表示されますので「このWebサイトを閲覧」から証明書を許可します。 ページが表示されればOKです。 補足 コンテナ起動時にApacheを自動起動する # CentOS systemctl enable httpd Apacheの設定ファイルの場所 # CentOS vi /etc/httpd/conf/httpd.conf PHPの設定ファイルの場所 # CentOS vi /etc/php.ini 最後に 最小限ですがPHPの開発環境を構築できました。あとはDBをインストールなど色々とカスタマイズしていきたいと思います。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Docker ComposeでWordPressのテーマ開発環境を一瞬で作成する

きっかけ WordPressでテーマ開発をする際、 用意された環境が本番環境しかないときがあります。 そんなとき、Dockerでローカル環境のWordPress検証環境をすぐに作れるようにしたく、 用意することにしました。 環境 Mac、WindowsどちらでもOK Docker、Docker Compose両方をインストール済 ディレクトリ構成 WordPressのローカル検証環境を立ち上げられば良いので、シンプルな構成にします。 まずはプロジェクト用の適当なフォルダを用意します。 (ここではwordpress-dockerという名前にしました。) wordpress-docker/ └─docker-compose.yml 開発用の空テーマをダウンロード 開発用の空テーマを用意します。 underscores.me というサイトから空テーマを取得することができます。 今回は、original-theme という名前のテーマを作成したいので、 original-themeと入力してダウンロードします。 このフォルダはWordPressコンテナのwp-content/themesにマウントしたいので、 ダウンロードしたら、wordpress-dockerディレクトリに配置します。 wordpress-docker/ ├─original-theme/ │ ├─inc │ ├─js │ ├─languages │ ├─... │ └─docker-compose.yml docker-compose.yml作成 wordpress-docker ディレクトリ配下に、docker-compose.ymlを作成します。 docker-compose.yml version: '3' services: db: image: mysql:5.7 ports: - "3307:3306" environment: MYSQL_ROOT_PASSWORD: rootwordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress volumes: - ./original-theme:/var/www/html/wp-content/themes/original-theme wordpress: depends_on: - db image: wordpress:latest ports: - "8001:80" environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: - db-data:/var/lib/mysql phpmyadmin: depends_on: - db image: phpmyadmin/phpmyadmin ports: - "8081:80" volumes: db-data: {} Docker起動 Docker Composeを使って立ち上げます。 $ docker-compose up -d アクセスする WordPressコンテナはポート8001で動かしているので、 http://localhost:8001にアクセスします。 WordPressのインストール画面が表示されれば成功です。 あとは、手順に沿えばWordPressのインストールは完了です。 phpMyAdminのコンテナもポート8081で追加しているので、 データベースにはhttp://localhost:8081でアクセスできます。 作成した空テンプレートを有効化する 先ほど作成した空テーマ original-theme を有効化します。 これでローカル環境でテーマ開発がいくらでもできますね! また wordpress-docker ディレクトリをGitで管理するようにしてしまえば、 複数人で開発するときにも便利です。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Jenkinsのmaster slave構成をDockerで構築する

はじめに この記事はDocker/Kubernetes実践コンテナ開発入門にて、 書籍通りに進めて詰まってしまった箇所の解決策を自分用にメモしています。 前提条件 一度Jenkinsのmasterノードをdockerで作成し、ssh公開鍵の作成は完了している。 用意するdocker-compose.yml version: "3" services: master: container_name: master image: jenkins/jenkins:latest ports: - 8080:8080 volumes: - ./jenkins_home:/var/jenkins_home links: - slave slave: container_name: slave image: jenkins/ssh-slave:latest environment: - JENKINS_SLAVE_SSH_PUBKEY=ssh-rsa AAAAB....... ※Jenkinsのサイトによると、 jenkinsciは開発が止まっているようです。。 実行 $docker-compose up -d #上記docker-compose.ymlを実行 Docker Compose is now in the Docker CLI, try `docker compose up` Starting slave01 ... done Starting master ... done 無事実行できました! ちなみに、jenkinsciのイメージでコンテナを作成すると、Jenkinsのpluginインストールでこけます。 masterノードへslaveノードを登録する ここも一山ありました。。 書籍通りに進めると、slaveノードに通信ができません。(java.IOExceptionが出ます) 解決策は、以下サイトに非常に丁寧に記載してくださっています。 jenkinsのmaster/slave間のSSH接続でjavaがないと言われた時の対処法(docker)
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む