前提・実現したいこと
docker環境でrails,mysqlのコンテナを作成後、rails newする段階で躓いております。
ファイルはそれぞれ以下のサイトを参考に作成しております。
https://qiita.com/kodai_0122/items/795438d738386c2c1966
発生している問題・エラーメッセージ
rails newしますと下記のようにexistと表示されたのち、railsファイル群が生成されますが、手元のリポジトリに生成したファイルが反映されません。
MacBook-Pro okonomiyakiApp % docker-compose run web rails new . --force --database=mysql --skip-bundle Starting okonomiyakiapp_mysql_1 ... done Creating okonomiyakiapp_web_run ... done exist create README.md create Rakefile create .ruby-version create config.ru create .gitignore create .gitattributes force Gemfile run git init from "." hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty Git repository in /okonomiyakiApp/.git/ ー以下create filepass続きますので省略ー remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_6_1.rb Skipping `rails webpacker:install` because `bundle install` was skipped. To complete setup, you must run `bundle install` followed by `rails webpacker:install`.
該当のソースコード
ご面倒おかけして申し訳ありませんが下記からご覧ください。
https://github.com/N-hiromi/okonomiyaki_db
試したこと
webコンテナに入ってrails newできていないから手元にファイルが反映されないのではと思い、docker-compose build, docker-compose up -dしたのち、docker-compose psしますと、やはり下記のようにコンテナが立ち上がっていないことがわかりました。
Name Command State Ports ------------------------------------------------------------------------ okonomiyakiapp_mysql_1 docker-entrypoint.sh mysqld Exit 1 okonomiyakiapp_web_1 entrypoint.sh bundle exec ... Exit 0
docker-compose logsしますと、mysqlコンテナはpasswordなどが設定されていないため、webコンテナはrailsアプリが生成されていないためerrorであるとありました。
MacBook-Pro okonomiyakiApp % docker-compose logs Attaching to okonomiyakiapp_web_1, okonomiyakiapp_mysql_1 mysql_1 | 2021-09-21 00:49:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.35-1debian10 started. mysql_1 | 2021-09-21 00:49:31+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' mysql_1 | 2021-09-21 00:49:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.35-1debian10 started. mysql_1 | 2021-09-21 00:49:31+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified mysql_1 | You need to specify one of the following: mysql_1 | - MYSQL_ROOT_PASSWORD mysql_1 | - MYSQL_ALLOW_EMPTY_PASSWORD mysql_1 | - MYSQL_RANDOM_ROOT_PASSWORD web_1 | Usage: web_1 | rails new APP_PATH [options] web_1 | web_1 | Options: web_1 | [--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated engines) web_1 | [--skip-collision-check], [--no-skip-collision-check] # Skip collision check web_1 | -r, [--ruby=PATH] # Path to the Ruby binary of your choice web_1 | # Default: /usr/local/bin/ruby web_1 | -m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL) web_1 | -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) web_1 | # Default: sqlite3 web_1 | [--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile web_1 | -G, [--skip-git], [--no-skip-git] # Skip .gitignore file web_1 | [--skip-keeps], [--no-skip-keeps] # Skip source control .keep files web_1 | -M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files web_1 | [--skip-action-mailbox], [--no-skip-action-mailbox] # Skip Action Mailbox gem web_1 | [--skip-action-text], [--no-skip-action-text] # Skip Action Text gem web_1 | -O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files web_1 | [--skip-active-job], [--no-skip-active-job] # Skip Active Job web_1 | [--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage files web_1 | -P, [--skip-puma], [--no-skip-puma] # Skip Puma related files web_1 | -C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files web_1 | -S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files web_1 | [--skip-spring], [--no-skip-spring] # Don't install Spring application preloader web_1 | [--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem web_1 | -J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files web_1 | [--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem web_1 | [--skip-jbuilder], [--no-skip-jbuilder] # Skip jbuilder gem web_1 | -T, [--skip-test], [--no-skip-test] # Skip test files web_1 | [--skip-system-test], [--no-skip-system-test] # Skip system test files web_1 | [--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem web_1 | [--dev], [--no-dev] # Set up the application with Gemfile pointing to your Rails checkout web_1 | [--edge], [--no-edge] # Set up the application with Gemfile pointing to Rails repository web_1 | [--master], [--no-master] # Set up the application with Gemfile pointing to Rails repository main branch web_1 | [--rc=RC] # Path to file containing extra configuration options for rails command web_1 | [--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file web_1 | [--api], [--no-api] # Preconfigure smaller stack for API only apps web_1 | [--minimal], [--no-minimal] # Preconfigure a minimal rails app web_1 | -B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install web_1 | --webpacker, [--webpack=WEBPACK] # Preconfigure Webpack with a particular framework (options: react, vue, angular, elm, stimulus) web_1 | [--skip-webpack-install], [--no-skip-webpack-install] # Don't run Webpack install web_1 | web_1 | Runtime options: web_1 | -f, [--force] # Overwrite files that already exist web_1 | -p, [--pretend], [--no-pretend] # Run but do not make any changes web_1 | -q, [--quiet], [--no-quiet] # Suppress status output web_1 | -s, [--skip], [--no-skip] # Skip files that already exist web_1 | web_1 | Rails options: web_1 | -h, [--help], [--no-help] # Show this help message and quit web_1 | -v, [--version], [--no-version] # Show Rails version number and quit web_1 | web_1 | Description: web_1 | The 'rails new' command creates a new Rails application with a default web_1 | directory structure and configuration at the path you specify. web_1 | web_1 | You can specify extra command-line arguments to be used every time web_1 | 'rails new' runs in the .railsrc configuration file in your home directory, web_1 | or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set. web_1 | web_1 | Note that the arguments specified in the .railsrc file don't affect the web_1 | defaults values shown above in this help message. web_1 | web_1 | Example: web_1 | rails new ~/Code/Ruby/weblog web_1 | web_1 | This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
rails newする前にrailsアプリが無いのは当たり前ですし、dbへの接続はこの後に行うのですが、このerrorがファイルが反映されないことの原因でしょうか?
"docker rails ファイルが作成できない"などのいくつかワードを変えて検索をしましたが該当する例が見つかりませんでした。
補足情報(FW/ツールのバージョンなど)
MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)を使用しています。docker環境作成は初めてであり、railsも学び始めて半年程度です。
環境作成に数日かけており、手探りの状態です。拙い点ばかりだと思いますがどなたかご指摘いただけますと幸いです。よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/09/22 05:35