開発環境
MacOS
Ruby2.7.2
Rails5.2.4
DB:PostgreSQL
困っていること
すでにRaulsでアプリはできています。これをDocker環境で動くようにしたいです。
下記のサイトを参考にDockerにチャンレンジしています。
https://nanayaku.com/docker-rails-postgresql/
その中で「 docker-compose run web rake db:create」を実行すると下記のエラーがでます。
エラー
Starting rails-minimum-skill-check_data_1 ... done Creating rails-minimum-skill-check_web_run ... done FATAL: password authentication failed for user "devuser" Couldn't create 'min-skill_development' database. Please check your configuration. rake aborted! PG::ConnectionBad: FATAL: password authentication failed for user "devuser" /usr/local/bundle/gems/pg-0.21.0/lib/pg.rb:56:in `initialize' /usr/local/bundle/gems/pg-0.21.0/lib/pg.rb:56:in `new' /usr/local/bundle/gems/pg-0.21.0/lib/pg.rb:56:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/connection_handling.rb:90:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:119:in `create' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:313:in `each' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/tasks/database_tasks.rb:138:in `create_current' /usr/local/bundle/gems/activerecord-5.2.4.5/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>' /usr/local/bundle/gems/rake-13.0.3/exe/rake:27:in `<top (required)>' Tasks: TOP => db:create (See full trace by running task with --trace) ERROR: 1
docker-compose.yml
data: image: busybox:latest volumes: - .:/app db: image: postgres:9.4 volumes_from: - data environment: POSTGRES_USER: devuser POSTGRES_PASSWORD: 'XXX(実際は入れています)' expose: - "5432" web: build: . command: bundle exec rails s -b 0.0.0.0 volumes_from: - data ports: - "3000:3000" links: - db environment: TZ: Asia/Tokyo LANG: C.UTF-8 RAILS_DATABASE_HOST: db
database.yml
default: &default adapter: postgresql timeout: 50000 pool: <%= ENV["DB_POOL"] || ENV["RAILS_MAX_THREADS"] || 5 %> development: <<: *default database: min-skill_development username: devuser password: XXX(実際は文字を入れています) host: <%= ENV['RAILS_DATABASE_HOST'] || 'localhost' %> test: <<: *default database: min-skill_test username: devuser host: <%= ENV['RAILS_DATABASE_HOST'] || 'localhost' %> production: <<: *default database: min-skill_production
わからない点
パスワードが正しくない、という内容だと思うのですが、何通りかパスワードを入力してもエラーが出てしまいます。
アドバイスいただけますと幸いです。
回答1件
あなたの回答
tips
プレビュー