docker-compose upして、http://localhost:3000/にアクセスすると
このようなエラーが起きてしまい困っています。
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
試したコマンド brew uninstall mysql brew install mysql sudo mysql.server start sudo touch /tmp/mysql.sock user@fukusyun-2 Books % mysql.server restart Shutting down MySQL . SUCCESS! Starting MySQL . SUCCESS!
ターミナル web_1 | web-console (4.0.4) lib/web_console/middleware.rb:19:in `block in call' web_1 | web-console (4.0.4) lib/web_console/middleware.rb:17:in `catch' web_1 | web-console (4.0.4) lib/web_console/middleware.rb:17:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:37:in `call_app' web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `block in call' web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `block in tagged' web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:28:in `tagged' web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `tagged' web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `call' web_1 | sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/request_id.rb:27:in `call' web_1 | rack (2.2.3) lib/rack/method_override.rb:24:in `call' web_1 | rack (2.2.3) lib/rack/runtime.rb:22:in `call' web_1 | activesupport (6.0.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/static.rb:126:in `call' web_1 | rack (2.2.3) lib/rack/sendfile.rb:110:in `call' web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/host_authorization.rb:82:in `call' web_1 | webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request' web_1 | rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call' web_1 | railties (6.0.3.2) lib/rails/engine.rb:527:in `call' web_1 | puma (3.12.6) lib/puma/configuration.rb:227:in `call' web_1 | puma (3.12.6) lib/puma/server.rb:706:in `handle_request' web_1 | puma (3.12.6) lib/puma/server.rb:476:in `process_client' web_1 | puma (3.12.6) lib/puma/server.rb:334:in `block in run' web_1 | puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
database.yml default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: password # socket: /tmp/mysql.sock host: db development: <<: *default database: Books_development test: <<: *default database: Books_test production: <<: *default database: Books_production username: Books password: <%= ENV['BOOKS_DATABASE_PASSWORD'] %> username: root password: <%= ENV['DATABASE_PASSWORD'] %> socket: /var/lib/mysql/mysql.sock
docker-compose.yml version: '3' services: db: command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: example image: mysql ports: - "4306:3306" web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/app_name ports: - "3000:3000" depends_on: - db
dockerfile FROM ruby:2.6 RUN apt-get update -qq && \ apt-get install -y build-essential \ libpq-dev \ nodejs RUN mkdir /Books ENV APP_ROOT /Books WORKDIR $APP_ROOT ADD ./Gemfile $APP_ROOT/Gemfile ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock RUN gem install bundler RUN bundle install ADD . $APP_ROOT
回答1件
あなたの回答
tips
プレビュー