質問編集履歴

3

タイトルと質問内容の修正

2019/08/06 01:32

投稿

zvub1123
zvub1123

スコア230

test CHANGED
@@ -1 +1 @@
1
- docker-compose から ecs-cli への移植につ
1
+ ecs-cli compose up で package.json が読み込めな
test CHANGED
@@ -22,9 +22,7 @@
22
22
 
23
23
  docker build -t $IMAGE_NAME .
24
24
 
25
- docker tag $IMAGE_NAME:latest $TAG_NAME:latest
25
+ docker tag $IMAGE_NAME:latest $TAG_NAME:latest && docker push $TAG_NAME:latest
26
-
27
- docker push $TAG_NAME:latest
28
26
 
29
27
 
30
28
 
@@ -50,33 +48,35 @@
50
48
 
51
49
 
52
50
 
53
- 上記の手順を実施した際、最後の `ecs-cli compose up` コマンドを実行した結果以下の通りです。
51
+ 上記の手順を実施した際、最後の `ecs-cli compose up` コマンドを実行した結果以下のようなエラーがCloudWatchに出力されてしまいます。
54
-
52
+
55
- ```
53
+ ```
54
+
56
-
55
+ npm ERR! path /usr/src/app/package.json
56
+
57
+ npm ERR! code ENOENT
58
+
59
+ npm ERR! errno -2
60
+
61
+ npm ERR! syscall open
62
+
57
- WARN[0000] Skipping unsupported YAML option for service... option name=depends_on service name=web
63
+ npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
58
-
59
- INFO[0000] Using ECS task definition TaskDefinition="XXXXX:21"
64
+
60
-
61
- WARN[0000] No log groups to create; no containers use 'awslogs'
65
+ npm ERR! enoent This is related to npm not being able to find a file.
66
+
62
-
67
+ npm ERR! enoent
68
+
69
+ npm ERR! A complete log of this run can be found in:
70
+
63
- INFO[0000] Starting container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo
71
+ npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
64
-
65
- INFO[0000] Starting container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web
72
+
66
-
67
- INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
68
-
69
- INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
70
-
71
- INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
72
-
73
- INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
74
-
75
- ```
73
+ ```
74
+
75
+
76
+
76
-
77
+ クラスタ内の mongo コンテナは正常に起動しているように見受けられるのですが、その後、webコンテナの起動中に何らかの原因で起動が失敗し、
77
-
78
-
78
+
79
- 記載の通り、コンテナStopしてしまう状態となっております。
79
+ タスク停止してしまう状況です。
80
80
 
81
81
 
82
82
 
@@ -84,6 +84,8 @@
84
84
 
85
85
 
86
86
 
87
+
88
+
87
89
  ```yaml
88
90
 
89
91
  # docker-compose.yml
@@ -96,89 +98,91 @@
96
98
 
97
99
  web:
98
100
 
99
- # image: vue-express-mongo-site
100
-
101
101
  image: $TAG_NAME:latest
102
102
 
103
- # build: .
104
-
105
103
  command: npm run docker-dev
106
104
 
107
105
  ports:
108
106
 
109
107
  - "3000:3000"
110
108
 
109
+ working_dir: /home/app
110
+
111
111
  volumes:
112
112
 
113
- - .:/usr/src/app
113
+ - .:/home/app
114
-
114
+
115
- - /usr/src/app/node_modules
115
+ - /home/app/node_modules
116
+
117
+ logging:
118
+
119
+ driver: "awslogs"
120
+
121
+ options:
122
+
123
+ awslogs-group: "/ecs/vue"
124
+
125
+ awslogs-region: "ap-northeast-1"
126
+
127
+ awslogs-stream-prefix: "macroscope-test"
116
128
 
117
129
  links:
118
130
 
119
131
  - "mongo"
120
132
 
133
+ mongo:
134
+
135
+ image: "mongo"
136
+
137
+ ports:
138
+
139
+ - "27017:27017"
140
+
121
141
  logging:
122
142
 
123
- driver: "awslogs"
143
+ driver: awslogs
124
144
 
125
145
  options:
126
146
 
127
- awslogs-group: "/ecs/vue"
147
+ awslogs-group: "/ecs/mongo"
128
148
 
129
149
  awslogs-region: "ap-northeast-1"
130
150
 
131
151
  awslogs-stream-prefix: "macroscope-test"
132
152
 
133
- mongo:
134
-
135
- image: "mongo"
136
-
137
- logging:
138
-
139
- driver: awslogs
140
-
141
- options:
142
-
143
- awslogs-group: "/ecs/mongo"
144
-
145
- awslogs-region: "ap-northeast-1"
146
-
147
- awslogs-stream-prefix: "macroscope-test"
148
-
149
- ports:
150
-
151
- - "27017:27017"
152
-
153
153
  ```
154
154
 
155
155
 
156
156
 
157
157
  ```Dockerfile
158
158
 
159
- FROM node:10.16.0-alpine
159
+ FROM node:10.16.0
160
-
161
-
160
+
161
+
162
162
 
163
163
  # Create app directory
164
164
 
165
+ ADD . /home/app
166
+
165
- WORKDIR /usr/src/app
167
+ WORKDIR /home/app
166
168
 
167
169
 
168
170
 
169
171
  # Install app dependencies
170
172
 
171
- COPY package.json .
173
+ ADD package.json .
172
-
173
-
174
-
174
+
175
+
176
+
175
- RUN npm install
177
+ RUN node -v && npm -v
178
+
179
+ RUN cd /home/app && npm install
176
180
 
177
181
 
178
182
 
179
183
  # Bundle app source
180
184
 
181
- COPY . .
185
+ ADD . /home/app
182
186
 
183
187
 
184
188
 
@@ -192,14 +196,6 @@
192
196
 
193
197
 
194
198
 
195
-
196
-
197
- イメージの元ネタは Icebob 氏の下記のリポジトリです。
198
-
199
- [vue-express-mongo-boilerplate](https://github.com/icebob/vue-express-mongo-boilerplate)
200
-
201
-
202
-
203
199
  問題解消のためにどこを参照すれば良いのかも定まらず、苦戦しています。
204
200
 
205
201
  docker-compose を ecs へ移植するために足りない設定などがあるのでしょうか。
@@ -209,41 +205,3 @@
209
205
 
210
206
 
211
207
  よろしくお願いします。
212
-
213
-
214
-
215
-
216
-
217
- 追記(2019/08/02)================================================================================
218
-
219
- cloudwatch にログを出力することができたため詳細を確認すると、web コンテナのログが以下のようになっておりました。
220
-
221
-
222
-
223
- ```
224
-
225
- npm ERR! path /usr/src/app/package.json
226
-
227
- npm ERR! code ENOENT
228
-
229
- npm ERR! errno -2
230
-
231
- npm ERR! syscall open
232
-
233
- npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
234
-
235
- npm ERR! enoent This is related to npm not being able to find a file.
236
-
237
- npm ERR! enoent
238
-
239
- npm ERR! A complete log of this run can be found in:
240
-
241
- npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
242
-
243
- ```
244
-
245
- package.json が見当たらない、と言われているようなのですが、パーミッション関連の問題なのでしょうか。
246
-
247
-
248
-
249
- ===============================================================================================

2

タグの編集

2019/08/06 01:32

投稿

zvub1123
zvub1123

スコア230

test CHANGED
File without changes
test CHANGED
File without changes

1

CloudWatchのログを追記

2019/08/02 08:45

投稿

zvub1123
zvub1123

スコア230

test CHANGED
File without changes
test CHANGED
@@ -18,26 +18,26 @@
18
18
 
19
19
  ```bash
20
20
 
21
- # Docker build
21
+ # Docker build and push
22
22
 
23
23
  docker build -t $IMAGE_NAME .
24
24
 
25
- # tagging
26
-
27
25
  docker tag $IMAGE_NAME:latest $TAG_NAME:latest
28
26
 
27
+ docker push $TAG_NAME:latest
28
+
29
29
 
30
30
 
31
31
  # ECS-CLI profile setting
32
32
 
33
33
  ecs-cli configure profile --profile-name $PROFILE_NAME --access-key $ACCESS_KEY --secret-key $SECRET_KEY
34
34
 
35
-
36
-
37
35
  # Cluster and Region setting
38
36
 
39
37
  ecs-cli configure --cluster $CLUSTER_NAME --default-launch-type EC2 --region ap-northeast-1 --config-name $CONFIG_NAME
40
38
 
39
+
40
+
41
41
  # Cluster Up
42
42
 
43
43
  ecs-cli up --keypair $KEY_PAIR_NAME --instance-role $ROLE_NAME --instance-type m4.large
@@ -68,10 +68,6 @@
68
68
 
69
69
  INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
70
70
 
71
- INFO[0012] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
72
-
73
- INFO[0012] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
74
-
75
71
  INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
76
72
 
77
73
  INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
@@ -102,7 +98,7 @@
102
98
 
103
99
  # image: vue-express-mongo-site
104
100
 
105
- image: $ACCOUNT_ID.dkr.ecr.ap-northeast-1.amazonaws.com/$IMAGE_NAME
101
+ image: $TAG_NAME:latest
106
102
 
107
103
  # build: .
108
104
 
@@ -118,15 +114,37 @@
118
114
 
119
115
  - /usr/src/app/node_modules
120
116
 
121
- depends_on:
117
+ links:
122
118
 
123
119
  - "mongo"
124
120
 
121
+ logging:
122
+
123
+ driver: "awslogs"
124
+
125
+ options:
126
+
127
+ awslogs-group: "/ecs/vue"
128
+
129
+ awslogs-region: "ap-northeast-1"
130
+
131
+ awslogs-stream-prefix: "macroscope-test"
132
+
125
133
  mongo:
126
134
 
127
135
  image: "mongo"
128
136
 
129
-
137
+ logging:
138
+
139
+ driver: awslogs
140
+
141
+ options:
142
+
143
+ awslogs-group: "/ecs/mongo"
144
+
145
+ awslogs-region: "ap-northeast-1"
146
+
147
+ awslogs-stream-prefix: "macroscope-test"
130
148
 
131
149
  ports:
132
150
 
@@ -191,3 +209,41 @@
191
209
 
192
210
 
193
211
  よろしくお願いします。
212
+
213
+
214
+
215
+
216
+
217
+ 追記(2019/08/02)================================================================================
218
+
219
+ cloudwatch にログを出力することができたため詳細を確認すると、web コンテナのログが以下のようになっておりました。
220
+
221
+
222
+
223
+ ```
224
+
225
+ npm ERR! path /usr/src/app/package.json
226
+
227
+ npm ERR! code ENOENT
228
+
229
+ npm ERR! errno -2
230
+
231
+ npm ERR! syscall open
232
+
233
+ npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
234
+
235
+ npm ERR! enoent This is related to npm not being able to find a file.
236
+
237
+ npm ERR! enoent
238
+
239
+ npm ERR! A complete log of this run can be found in:
240
+
241
+ npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
242
+
243
+ ```
244
+
245
+ package.json が見当たらない、と言われているようなのですが、パーミッション関連の問題なのでしょうか。
246
+
247
+
248
+
249
+ ===============================================================================================