質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -211,3 +211,193 @@
|
|
211
211
|
どなたか知見のある方教えていただけないででしょうか?
|
212
212
|
|
213
213
|
「ここが怪しい!」とかでも教えていただけると幸いです。
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
## 追記
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
docker-compose.ymlからrailsコンテナのportsの宣言を削除しました。
|
242
|
+
|
243
|
+
```
|
244
|
+
|
245
|
+
version: '2'
|
246
|
+
|
247
|
+
services:
|
248
|
+
|
249
|
+
rails: &app_base
|
250
|
+
|
251
|
+
build:
|
252
|
+
|
253
|
+
context: .
|
254
|
+
|
255
|
+
dockerfile: "Dockerfile.dev"
|
256
|
+
|
257
|
+
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
|
258
|
+
|
259
|
+
env_file:
|
260
|
+
|
261
|
+
- "./.env.dev"
|
262
|
+
|
263
|
+
volumes:
|
264
|
+
|
265
|
+
- ".:/app"
|
266
|
+
|
267
|
+
volumes_from:
|
268
|
+
|
269
|
+
- data
|
270
|
+
|
271
|
+
ports:
|
272
|
+
|
273
|
+
- "3000:3000"
|
274
|
+
|
275
|
+
depends_on:
|
276
|
+
|
277
|
+
- db
|
278
|
+
|
279
|
+
tty: true
|
280
|
+
|
281
|
+
stdin_open: true
|
282
|
+
|
283
|
+
spring:
|
284
|
+
|
285
|
+
<<: *app_base
|
286
|
+
|
287
|
+
command: ["bundle", "exec", "spring", "server"]
|
288
|
+
|
289
|
+
ports: []
|
290
|
+
|
291
|
+
tty: false
|
292
|
+
|
293
|
+
stdin_open: false
|
294
|
+
|
295
|
+
db:
|
296
|
+
|
297
|
+
image: "mysql:5.6"
|
298
|
+
|
299
|
+
environment:
|
300
|
+
|
301
|
+
- "MYSQL_USER=mysql"
|
302
|
+
|
303
|
+
- "MYSQL_PASSWORD=password"
|
304
|
+
|
305
|
+
volumes_from:
|
306
|
+
|
307
|
+
- data
|
308
|
+
|
309
|
+
data:
|
310
|
+
|
311
|
+
image: "busybox"
|
312
|
+
|
313
|
+
volumes:
|
314
|
+
|
315
|
+
- "db:/var/lib/mysql"
|
316
|
+
|
317
|
+
- "bundle:/usr/local/bundle"
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
volumes:
|
322
|
+
|
323
|
+
db:
|
324
|
+
|
325
|
+
driver: local
|
326
|
+
|
327
|
+
bundle:
|
328
|
+
|
329
|
+
driver: local
|
330
|
+
|
331
|
+
```
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
database.ymlからもportの設定を削除しました
|
338
|
+
|
339
|
+
config/database.yml
|
340
|
+
|
341
|
+
```
|
342
|
+
|
343
|
+
default: &default
|
344
|
+
|
345
|
+
adapter: mysql2
|
346
|
+
|
347
|
+
encoding: utf8
|
348
|
+
|
349
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
350
|
+
|
351
|
+
username: <%= ENV.fetch('DATABASE_USER') { 'root' } %>
|
352
|
+
|
353
|
+
password: <%= ENV.fetch('DATABASE_PASSWORD') { 'password' } %>
|
354
|
+
|
355
|
+
host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
development:
|
360
|
+
|
361
|
+
<<: *default
|
362
|
+
|
363
|
+
database: app_development
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
test:
|
368
|
+
|
369
|
+
<<: *default
|
370
|
+
|
371
|
+
database: app_test
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
production:
|
376
|
+
|
377
|
+
<<: *default
|
378
|
+
|
379
|
+
database: app_production
|
380
|
+
|
381
|
+
```
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
.env,dev
|
386
|
+
|
387
|
+
```
|
388
|
+
|
389
|
+
DATABASE_HOST=db
|
390
|
+
|
391
|
+
DATABASE_USER=mysql
|
392
|
+
|
393
|
+
DATABASE_PASSWORD=password
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
```
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
これでも#<Mysql2::Error: Unknown MySQL server host 'db' (25)>が出てしまいます・・・
|