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

質問編集履歴

3

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

2019/08/06 01:32

投稿

zvub1123
zvub1123

スコア230

title CHANGED
@@ -1,1 +1,1 @@
1
- docker-compose から ecs-cli への移植につ
1
+ ecs-cli compose up package.json が読み込めな
body CHANGED
@@ -10,8 +10,7 @@
10
10
  ```bash
11
11
  # Docker build and push
12
12
  docker build -t $IMAGE_NAME .
13
- docker tag $IMAGE_NAME:latest $TAG_NAME:latest
13
+ docker tag $IMAGE_NAME:latest $TAG_NAME:latest && docker push $TAG_NAME:latest
14
- docker push $TAG_NAME:latest
15
14
 
16
15
  # ECS-CLI profile setting
17
16
  ecs-cli configure profile --profile-name $PROFILE_NAME --access-key $ACCESS_KEY --secret-key $SECRET_KEY
@@ -24,102 +23,82 @@
24
23
  ecs-cli compose up --create-log-groups --cluster $CLUSTER_NAME
25
24
  ```
26
25
 
27
- 上記の手順を実施した際、最後の `ecs-cli compose up` コマンドを実行した結果以下の通りです。
26
+ 上記の手順を実施した際、最後の `ecs-cli compose up` コマンドを実行した結果以下のようなエラーがCloudWatchに出力されてしまいます。
28
27
  ```
28
+ npm ERR! path /usr/src/app/package.json
29
+ npm ERR! code ENOENT
30
+ npm ERR! errno -2
31
+ npm ERR! syscall open
29
- WARN[0000] Skipping unsupported YAML option for service... option name=depends_on service name=web
32
+ npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
30
- INFO[0000] Using ECS task definition TaskDefinition="XXXXX:21"
31
- WARN[0000] No log groups to create; no containers use 'awslogs'
33
+ npm ERR! enoent This is related to npm not being able to find a file.
34
+ npm ERR! enoent
35
+ npm ERR! A complete log of this run can be found in:
32
- INFO[0000] Starting container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo
36
+ npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
33
- INFO[0000] Starting container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web
34
- INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
35
- INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
36
- INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
37
- INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
38
37
  ```
39
38
 
39
+ クラスタ内の mongo コンテナは正常に起動しているように見受けられるのですが、その後、webコンテナの起動中に何らかの原因で起動が失敗し、
40
- 記載の通り、コンテナStopしてしまう状態となっております。
40
+ タスク停止してしまう状況です。
41
41
 
42
42
  docker-compose.yml ファイル及び Dockerfile の記載内容は以下の通りです。
43
43
 
44
+
44
45
  ```yaml
45
46
  # docker-compose.yml
46
47
 
47
48
  version: '3'
48
49
  services:
49
50
  web:
50
- # image: vue-express-mongo-site
51
51
  image: $TAG_NAME:latest
52
- # build: .
53
52
  command: npm run docker-dev
54
53
  ports:
55
54
  - "3000:3000"
55
+ working_dir: /home/app
56
56
  volumes:
57
- - .:/usr/src/app
57
+ - .:/home/app
58
- - /usr/src/app/node_modules
58
+ - /home/app/node_modules
59
- links:
60
- - "mongo"
61
59
  logging:
62
60
  driver: "awslogs"
63
61
  options:
64
62
  awslogs-group: "/ecs/vue"
65
63
  awslogs-region: "ap-northeast-1"
66
64
  awslogs-stream-prefix: "macroscope-test"
65
+ links:
66
+ - "mongo"
67
67
  mongo:
68
68
  image: "mongo"
69
+ ports:
70
+ - "27017:27017"
69
71
  logging:
70
72
  driver: awslogs
71
73
  options:
72
74
  awslogs-group: "/ecs/mongo"
73
75
  awslogs-region: "ap-northeast-1"
74
76
  awslogs-stream-prefix: "macroscope-test"
75
- ports:
76
- - "27017:27017"
77
77
  ```
78
78
 
79
79
  ```Dockerfile
80
- FROM node:10.16.0-alpine
80
+ FROM node:10.16.0
81
-
81
+
82
82
  # Create app directory
83
+ ADD . /home/app
83
- WORKDIR /usr/src/app
84
+ WORKDIR /home/app
84
85
 
85
86
  # Install app dependencies
86
- COPY package.json .
87
+ ADD package.json .
87
88
 
88
- RUN npm install
89
+ RUN node -v && npm -v
90
+ RUN cd /home/app && npm install
89
91
 
90
92
  # Bundle app source
91
- COPY . .
93
+ ADD . /home/app
92
94
 
93
95
  EXPOSE 3000
94
96
  ```
95
97
 
96
98
  イメージをpullするためにECR Repositoryも作成済みです。
97
99
 
98
-
99
- イメージの元ネタは Icebob 氏の下記のリポジトリです。
100
- [vue-express-mongo-boilerplate](https://github.com/icebob/vue-express-mongo-boilerplate)
101
-
102
100
  問題解消のためにどこを参照すれば良いのかも定まらず、苦戦しています。
103
101
  docker-compose を ecs へ移植するために足りない設定などがあるのでしょうか。
104
102
  ご助力いただけると幸いです。
105
103
 
106
- よろしくお願いします。
104
+ よろしくお願いします。
107
-
108
-
109
- 追記(2019/08/02)================================================================================
110
- cloudwatch にログを出力することができたため詳細を確認すると、web コンテナのログが以下のようになっておりました。
111
-
112
- ```
113
- npm ERR! path /usr/src/app/package.json
114
- npm ERR! code ENOENT
115
- npm ERR! errno -2
116
- npm ERR! syscall open
117
- npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
118
- npm ERR! enoent This is related to npm not being able to find a file.
119
- npm ERR! enoent
120
- npm ERR! A complete log of this run can be found in:
121
- npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
122
- ```
123
- package.json が見当たらない、と言われているようなのですが、パーミッション関連の問題なのでしょうか。
124
-
125
- ===============================================================================================

2

タグの編集

2019/08/06 01:32

投稿

zvub1123
zvub1123

スコア230

title CHANGED
File without changes
body CHANGED
File without changes

1

CloudWatchのログを追記

2019/08/02 08:45

投稿

zvub1123
zvub1123

スコア230

title CHANGED
File without changes
body CHANGED
@@ -8,16 +8,16 @@
8
8
  実行したコマンドは以下のような順序です。
9
9
 
10
10
  ```bash
11
- # Docker build
11
+ # Docker build and push
12
12
  docker build -t $IMAGE_NAME .
13
- # tagging
14
13
  docker tag $IMAGE_NAME:latest $TAG_NAME:latest
14
+ docker push $TAG_NAME:latest
15
15
 
16
16
  # ECS-CLI profile setting
17
17
  ecs-cli configure profile --profile-name $PROFILE_NAME --access-key $ACCESS_KEY --secret-key $SECRET_KEY
18
-
19
18
  # Cluster and Region setting
20
19
  ecs-cli configure --cluster $CLUSTER_NAME --default-launch-type EC2 --region ap-northeast-1 --config-name $CONFIG_NAME
20
+
21
21
  # Cluster Up
22
22
  ecs-cli up --keypair $KEY_PAIR_NAME --instance-role $ROLE_NAME --instance-type m4.large
23
23
  # deploy config file to cluster
@@ -33,8 +33,6 @@
33
33
  INFO[0000] Starting container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web
34
34
  INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
35
35
  INFO[0000] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
36
- INFO[0012] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
37
- INFO[0012] Describe ECS container status container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=RUNNING lastStatus=PENDING taskDefinition="XXXXX:21"
38
36
  INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/web desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
39
37
  INFO[0018] Stopped container... container=6ff23c6b-8ff9-4c20-97fa-0a882f1ce3a1/mongo desiredStatus=STOPPED lastStatus=STOPPED taskDefinition="XXXXX:21"
40
38
  ```
@@ -50,7 +48,7 @@
50
48
  services:
51
49
  web:
52
50
  # image: vue-express-mongo-site
53
- image: $ACCOUNT_ID.dkr.ecr.ap-northeast-1.amazonaws.com/$IMAGE_NAME
51
+ image: $TAG_NAME:latest
54
52
  # build: .
55
53
  command: npm run docker-dev
56
54
  ports:
@@ -58,11 +56,22 @@
58
56
  volumes:
59
57
  - .:/usr/src/app
60
58
  - /usr/src/app/node_modules
61
- depends_on:
59
+ links:
62
60
  - "mongo"
61
+ logging:
62
+ driver: "awslogs"
63
+ options:
64
+ awslogs-group: "/ecs/vue"
65
+ awslogs-region: "ap-northeast-1"
66
+ awslogs-stream-prefix: "macroscope-test"
63
67
  mongo:
64
68
  image: "mongo"
65
-
69
+ logging:
70
+ driver: awslogs
71
+ options:
72
+ awslogs-group: "/ecs/mongo"
73
+ awslogs-region: "ap-northeast-1"
74
+ awslogs-stream-prefix: "macroscope-test"
66
75
  ports:
67
76
  - "27017:27017"
68
77
  ```
@@ -94,4 +103,23 @@
94
103
  docker-compose を ecs へ移植するために足りない設定などがあるのでしょうか。
95
104
  ご助力いただけると幸いです。
96
105
 
97
- よろしくお願いします。
106
+ よろしくお願いします。
107
+
108
+
109
+ 追記(2019/08/02)================================================================================
110
+ cloudwatch にログを出力することができたため詳細を確認すると、web コンテナのログが以下のようになっておりました。
111
+
112
+ ```
113
+ npm ERR! path /usr/src/app/package.json
114
+ npm ERR! code ENOENT
115
+ npm ERR! errno -2
116
+ npm ERR! syscall open
117
+ npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
118
+ npm ERR! enoent This is related to npm not being able to find a file.
119
+ npm ERR! enoent
120
+ npm ERR! A complete log of this run can be found in:
121
+ npm ERR! /root/.npm/_logs/2019-08-01T04_54_49_065Z-debug.log
122
+ ```
123
+ package.json が見当たらない、と言われているようなのですが、パーミッション関連の問題なのでしょうか。
124
+
125
+ ===============================================================================================