動作確認をしたく、サーバーを立ち上げたいのですがうまくいきません。
どのよう手順が必要なのでしょうか。
やってみたこととしては、docker-compose.yml内の編集です。
api_1 | Mysql2::Error::ConnectionError (Unknown MySQL server host 'db' (-2)): api_1 | api_1 | mysql2 (0.5.3) lib/mysql2/client.rb:90:in `connect' api_1 | mysql2 (0.5.3) lib/mysql2/client.rb:90:in `initialize' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `new' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/mysql2_adapter.rb:24:in `mysql2_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in `new_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `checkout_new_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in `try_to_checkout_new_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in `acquire_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in `connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in `retrieve_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_handling.rb:221:in `retrieve_connection' api_1 | activerecord (6.0.3.1) lib/active_record/connection_handling.rb:189:in `connection' api_1 | activerecord (6.0.3.1) lib/active_record/migration.rb:562:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call' api_1 | activesupport (6.0.3.1) lib/active_support/callbacks.rb:101:in `run_callbacks' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/executor.rb:14:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' api_1 | railties (6.0.3.1) lib/rails/rack/logger.rb:37:in `call_app' api_1 | railties (6.0.3.1) lib/rails/rack/logger.rb:26:in `block in call' api_1 | activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:80:in `block in tagged' api_1 | activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:28:in `tagged' api_1 | activesupport (6.0.3.1) lib/active_support/tagged_logging.rb:80:in `tagged' api_1 | railties (6.0.3.1) lib/rails/rack/logger.rb:26:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/request_id.rb:27:in `call' api_1 | rack (2.2.2) lib/rack/runtime.rb:22:in `call' api_1 | activesupport (6.0.3.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/executor.rb:14:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/static.rb:126:in `call' api_1 | rack (2.2.2) lib/rack/sendfile.rb:110:in `call' api_1 | actionpack (6.0.3.1) lib/action_dispatch/middleware/host_authorization.rb:82:in `call' api_1 | railties (6.0.3.1) lib/rails/engine.rb:527:in `call' api_1 | puma (4.3.5) lib/puma/configuration.rb:228:in `call' api_1 | puma (4.3.5) lib/puma/server.rb:713:in `handle_request' api_1 | puma (4.3.5) lib/puma/server.rb:472:in `process_client' api_1 | puma (4.3.5) lib/puma/server.rb:328:in `block in run' api_1 | puma (4.3.5) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
version: '3' services: app: build: ./app tty: true volumes: - ./app:/app - app_node_modules:/app/node_modules ports: - '4000:4000' db: image: mysql:5.7 environment: MYSQL_DATABASE: root MYSQL_ROOT_PASSWORD: password ports: - '3306:3306' volumes: - db_data:/var/lib/mysql api: build: ./api command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ./api:/api ports: - '3000:3000' links: - db volumes: app_node_modules: db_data:
# MySQL. Versions 5.5.8 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: <%= ENV.fetch("MYSQL_DATABASE") { "root" } %> password: <%= ENV.fetch("MYSQL_ROOT_PASSWORD") { "password" } %> host: db development: <<: *default database: home_care_navi_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: home_care_navi_test # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: home_care_navi_production username: home_care_navi password: <%= ENV['home_care_navi_DATABASE_PASSWORD'] %>
回答1件
あなたの回答
tips
プレビュー