質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

Q&A

0回答

688閲覧

DockerでRailsサーバーを立ち上げることができない...

_chii

総合スコア50

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Docker

Dockerは、Docker社が開発したオープンソースのコンテナー管理ソフトウェアの1つです

0グッド

0クリップ

投稿2020/05/16 05:14

前提・実現したいこと

DockerでRailsのローカルサーバーを立ち上げることを目的にDockerを用いて環境を構築しているのですが、最後の段階の$ docker-compose run web rake db:createを実行し、ブラウザ上で動作が確認できることを表すお馴染みの楽しそうなイラストの画面を表示させたかったのですが最後のエラーにつまずきエラーが発生しています。ご教授頂けましたら幸いです。

発生している問題・エラーメッセージ

エラーの内容を説明致します。ローカルホストで立ち上げようとするとこちらのエラーが発生します。
イメージ説明

調べたところパスワードの未設定が原因だということがわかりました。なので下記のようにdatebase.ymlにパスワードを設定しました。

default: &default adapter: postgresql encoding: unicode host: db username: postgres password: postgres ←パスワードの設定をしました pool: 5 development: <<: *default database: myapp_development test: <<: *default database: myapp_test

そしてその後にきちんとdocker-compose run web bundle exec rake db:migrateを実行してからサイド立ち上げようとしても同じ当初のエラーから変わりませんでした...エラー内容が変わらないということは変更が反映されていないんだ。ということはわかっているので再度$ docker-compose run web rake db:createを試してみたり、あるいは他のパスワードに変更してみたりとして変化を確かめましたがパスワード設定前とエラー内容が変わらないという不思議な状態に頭を抱えています。

ちなみにターミナル上の記述は以下になります。

パスワードを変更したあとにdocker-compose run web bundle exec rake db:migrateを実行

ChisakinoMacBook-Pro:docker_sample Chisaki$ docker-compose run web bundle exec rake db:migrate Starting docker_sample_db_1 ... done rake aborted! PG::ConnectionBad: FATAL: password authentication failed for user "postgres" /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `initialize' /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `new' /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:90:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:172:in `migrate' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:60:in `block (2 levels) in <top (required)>' /usr/local/bundle/gems/rake-13.0.1/exe/rake:27:in `<top (required)>' /usr/local/bin/bundle:30:in `block in <main>' /usr/local/bin/bundle:22:in `<main>' Tasks: TOP => db:migrate (See full trace by running task with --trace)

DB作成時docker-compose run web rake db:createの実行

ChisakinoMacBook-Pro:docker_sample Chisaki$ docker-compose run web rake db:create Starting docker_sample_db_1 ... done FATAL: password authentication failed for user "postgres" Couldn't create 'myapp_development' database. Please check your configuration. rake aborted! PG::ConnectionBad: FATAL: password authentication failed for user "postgres" /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `initialize' /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `new' /usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:90:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:119:in `create' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:313:in `each' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/tasks/database_tasks.rb:138:in `create_current' /usr/local/bundle/gems/activerecord-5.2.4.2/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>' /usr/local/bundle/gems/rake-13.0.1/exe/rake:27:in `<top (required)>' Tasks: TOP => db:create (See full trace by running task with --trace) ChisakinoMacBook-Pro:docker_sample Chisaki$

ちなみにパスワードの設定はpostgresという単語とpasswordの2つを試したのでそれがターミナル上の記述に反映されているかもしれませんのでお含みおき下さい。

補足情報(FW/ツールのバージョンなど)

docker 19.03.8
MacOS

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

NCC1701

2020/05/16 19:23

docker-compose.ymlに原因がありそうなので、掲載されたし。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問