回答編集履歴

1

docker-compose.yml のdbコンテナの修正イメージを追記

2020/05/05 07:43

投稿

mit0223
mit0223

スコア3401

test CHANGED
@@ -35,3 +35,75 @@
35
35
  ```
36
36
 
37
37
  でコンテナを落として削除してください。
38
+
39
+
40
+
41
+ ---
42
+
43
+ 2020/5/5 コメントを受けて追記
44
+
45
+ dbコンテナが起動しない問題について
46
+
47
+
48
+
49
+ > db_1 | Error: Database is uninitialized and superuser password is not specified.
50
+
51
+ db_1 | You must specify POSTGRES_PASSWORD to a non-empty value for the
52
+
53
+ db_1 | superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
54
+
55
+
56
+
57
+ というエラーが出ています。[dockerhub の postgres の README](https://hub.docker.com/_/postgres)にもあるように postgres のコンテナでは POSTGRES_PASSWORD は必須となっています。また、ユーザIDはPOSTGRES_USER という環境変数で指定することになっています。
58
+
59
+
60
+
61
+ docker-compose.yml のdbコンテナの環境変数指定部分を修正してください。
62
+
63
+ 修正前:
64
+
65
+ ```Dockerfile
66
+
67
+ db:
68
+
69
+ build:
70
+
71
+ context: .
72
+
73
+ dockerfile: ./.docker/postgresql/Dockerfile
74
+
75
+ volumes:
76
+
77
+ - ./.docker/postgresql/volumes:/var/lib/postgresql/data
78
+
79
+ environment:
80
+
81
+ - DATABASE_USER=postgres
82
+
83
+ - DATABASE_PASSWORD=password
84
+
85
+ ```
86
+
87
+ 修正後:
88
+
89
+ ```Dockerfile
90
+
91
+ db:
92
+
93
+ build:
94
+
95
+ context: .
96
+
97
+ dockerfile: ./.docker/postgresql/Dockerfile
98
+
99
+ volumes:
100
+
101
+ - ./.docker/postgresql/volumes:/var/lib/postgresql/data
102
+
103
+ environment:
104
+
105
+ - POSTGRES_USER=postgres
106
+
107
+ - POSTGRES_PASSWORD=password
108
+
109
+ ```