teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

修正

2020/09/04 07:02

投稿

tomsuma
tomsuma

スコア38

title CHANGED
File without changes
body CHANGED
@@ -97,4 +97,54 @@
97
97
  username: root
98
98
  password: <%= ENV['DATABASE_PASSWORD'] %>
99
99
  socket: /var/lib/mysql/mysql.sock
100
+ ```
101
+
102
+ ```
103
+ docker-compose.yml
104
+
105
+ version: '3'
106
+ services:
107
+ db:
108
+ command: --default-authentication-plugin=mysql_native_password
109
+ restart: always
110
+ environment:
111
+ MYSQL_ROOT_PASSWORD: example
112
+ image: mysql
113
+ ports:
114
+ - "4306:3306"
115
+
116
+ web:
117
+ build: .
118
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
119
+ volumes:
120
+ - .:/app_name
121
+ ports:
122
+ - "3000:3000"
123
+ depends_on:
124
+ - db
125
+ ```
126
+
127
+ ```
128
+
129
+ dockerfile
130
+
131
+
132
+ FROM ruby:2.6
133
+
134
+ RUN apt-get update -qq && \
135
+ apt-get install -y build-essential \
136
+ libpq-dev \
137
+ nodejs
138
+
139
+ RUN mkdir /Books
140
+
141
+ ENV APP_ROOT /Books
142
+ WORKDIR $APP_ROOT
143
+
144
+ ADD ./Gemfile $APP_ROOT/Gemfile
145
+ ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock
146
+
147
+ RUN gem install bundler
148
+ RUN bundle install
149
+ ADD . $APP_ROOT
100
150
  ```

2

修正

2020/09/04 07:02

投稿

tomsuma
tomsuma

スコア38

title CHANGED
File without changes
body CHANGED
@@ -33,4 +33,68 @@
33
33
  . SUCCESS!
34
34
  Starting MySQL
35
35
  . SUCCESS!
36
+ ```
37
+
38
+ ```
39
+ ターミナル
40
+
41
+ web_1 | web-console (4.0.4) lib/web_console/middleware.rb:19:in `block in call'
42
+ web_1 | web-console (4.0.4) lib/web_console/middleware.rb:17:in `catch'
43
+ web_1 | web-console (4.0.4) lib/web_console/middleware.rb:17:in `call'
44
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
45
+ web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:37:in `call_app'
46
+ web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `block in call'
47
+ web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `block in tagged'
48
+ web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:28:in `tagged'
49
+ web_1 | activesupport (6.0.3.2) lib/active_support/tagged_logging.rb:80:in `tagged'
50
+ web_1 | railties (6.0.3.2) lib/rails/rack/logger.rb:26:in `call'
51
+ web_1 | sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
52
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
53
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
54
+ web_1 | rack (2.2.3) lib/rack/method_override.rb:24:in `call'
55
+ web_1 | rack (2.2.3) lib/rack/runtime.rb:22:in `call'
56
+ web_1 | activesupport (6.0.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
57
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
58
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/static.rb:126:in `call'
59
+ web_1 | rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
60
+ web_1 | actionpack (6.0.3.2) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
61
+ web_1 | webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
62
+ web_1 | rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
63
+ web_1 | railties (6.0.3.2) lib/rails/engine.rb:527:in `call'
64
+ web_1 | puma (3.12.6) lib/puma/configuration.rb:227:in `call'
65
+ web_1 | puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
66
+ web_1 | puma (3.12.6) lib/puma/server.rb:476:in `process_client'
67
+ web_1 | puma (3.12.6) lib/puma/server.rb:334:in `block in run'
68
+ web_1 | puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
69
+ ```
70
+
71
+ ```
72
+ database.yml
73
+
74
+ default: &default
75
+ adapter: mysql2
76
+ encoding: utf8
77
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
78
+ username: root
79
+ password: password
80
+ # socket: /tmp/mysql.sock
81
+
82
+ host: db
83
+
84
+ development:
85
+ <<: *default
86
+ database: Books_development
87
+
88
+ test:
89
+ <<: *default
90
+ database: Books_test
91
+
92
+ production:
93
+ <<: *default
94
+ database: Books_production
95
+ username: Books
96
+ password: <%= ENV['BOOKS_DATABASE_PASSWORD'] %>
97
+ username: root
98
+ password: <%= ENV['DATABASE_PASSWORD'] %>
99
+ socket: /var/lib/mysql/mysql.sock
36
100
  ```

1

修正

2020/09/04 06:26

投稿

tomsuma
tomsuma

スコア38

title CHANGED
File without changes
body CHANGED
@@ -6,6 +6,8 @@
6
6
  Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
7
7
 
8
8
  が出て困っています。。
9
+ [エラー時参考](https://qiita.com/carotene4035/items/e00076fe3990b9178cc0)
10
+ [docker参考](https://qiita.com/momokan928/items/d560fff3855fcbe0b811#1dockerfiledocker-composeyml%E3%82%92%E6%97%A2%E5%AD%98%E3%82%A2%E3%83%97%E3%83%AA%E3%81%AE%E3%83%AB%E3%83%BC%E3%83%88%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%AB%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B)
9
11
 
10
12
  ![エラー](5b685afc7a95590d6baf3176c07ab0f3.png)
11
13