태스크 정의에 2개의 컨테이너를 추가해 한쪽만 push해 서비스 업데이트했을 때의 거동

7285 단어 ECSAWS

목적



태스크 정의에 2개의 컨테이너 이미지를 등록해, 한쪽의 이미지만 갱신해, 서비스 갱신했을 때의 움직임을 확인한다

결론



둘 다 업데이트됨
원래 이미지 갱신하지 않아도 재배포되기 때문에 당연한 것입니다. .

사전 상태



ECS 클러스터의 EC2에 로그인하여 docker ps를 실행한 결과


$ docker ps
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS              PORTS                     NAMES
5d66e321abf7        *******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs   "node /src/bin/www &"    43 seconds ago      Up 41 seconds       0.0.0.0:32771->3000/tcp   ecs-p-test-node-ec2-12-my-nodejs-a0c3fdc992f6b3f47900
096f927e65a8        ******.dkr.ecr.ap-northeast-1.amazonaws.com/xray        "/usr/bin/xray -b 0.…"   43 seconds ago      Up 42 seconds       0.0.0.0:32771->2000/udp   ecs-p-test-node-ec2-12-xray-deamon-fcaed0fd81cb81d0cd01
b32773c2cb96        amazon/amazon-ecs-agent:latest                                "/agent"                 10 minutes ago      Up 10 minutes                                 ecs-agent

작업 정의


      "image": "******.dkr.ecr.ap-northeast-1.amazonaws.com/xray",
      "image": "******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs",

ECR



my-nodejs 업데이트


현재는, 2018/11/11/22:14의 이미지가 최신


절차



my-nodejs의 Push


$(aws ecr get-login --no-include-email --region ap-northeast-1)
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /Users/atsum/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

$ docker build -t my-nodejs .
Sending build context to Docker daemon  53.87MB
Step 1/6 : FROM node
 ---> 4e4c445311e6
Step 2/6 : RUN npm config set strict-ssl false;cd /src; npm install express;npm install aws-sdk;npm install aws-xray-sdk
 ---> Using cache
 ---> e1119dabe9de
Step 3/6 : COPY ./sampleapp /src
 ---> Using cache
 ---> dca5910601b9
Step 4/6 : RUN touch a.txt
 ---> Running in d21560d6bf43
Removing intermediate container d21560d6bf43
 ---> 3b2e08fee0a8
Step 5/6 : EXPOSE  3000
 ---> Running in 27d0f44837b2
Removing intermediate container 27d0f44837b2
 ---> f0ad9689a5d6
Step 6/6 : CMD ["node", "/src/bin/www", "&"]
 ---> Running in e9a308a9f0d2
Removing intermediate container e9a308a9f0d2
 ---> ba1fb6350c96
Successfully built ba1fb6350c96
Successfully tagged my-nodejs:latest

$ docker tag my-nodejs:latest ******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs:latest

$ docker push ******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs:latest
The push refers to repository [******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs]
f47635bb058a: Pushed 
8ff354860706: Layer already exists 
0fa739427d72: Layer already exists 
91072b192927: Layer already exists 
a6611280a43a: Layer already exists 
c4d021050ecd: Layer already exists 
9978d084fd77: Layer already exists 
1191b3f5862a: Layer already exists 
08a01612ffca: Layer already exists 
8bb25f9cdc41: Layer already exists 
f715ed19c28b: Layer already exists 
latest: digest: sha256:4eb1b6e76da52b6f078f7098922d5893a00ca701f141d66d47dc4a116b7ac171 size: 2637

이미지가 업데이트되었습니다.



서비스 업데이트



서비스를 선택하고 업데이트를 클릭


개정판에 최신을 지정하고 새 배포 강제 확인란을 클릭하여 서비스 업데이트



새 작업이 시작됨



확인



새 태스크 정의로 태스크 시작
$ docker ps
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED              STATUS              PORTS                     NAMES
537811dea3fd        ******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs   "node /src/bin/www &"    About a minute ago   Up About a minute   0.0.0.0:32772->3000/tcp   ecs-p-test-node-ec2-12-my-nodejs-b8dcc0b588d5e0e67600
7baf08f94a2e        ******.dkr.ecr.ap-northeast-1.amazonaws.com/xray        "/usr/bin/xray -b 0.…"   About a minute ago   Up About a minute   0.0.0.0:32772->2000/udp   ecs-p-test-node-ec2-12-xray-deamon-9ab1b4b2beb8fd919701
5d66e321abf7        b13bb187ade5                                                  "node /src/bin/www &"    25 minutes ago       Up 25 minutes       0.0.0.0:32771->3000/tcp   ecs-p-test-node-ec2-12-my-nodejs-a0c3fdc992f6b3f47900
096f927e65a8        ******.dkr.ecr.ap-northeast-1.amazonaws.com/xray        "/usr/bin/xray -b 0.…"   25 minutes ago       Up 25 minutes       0.0.0.0:32771->2000/udp   ecs-p-test-node-ec2-12-xray-deamon-fcaed0fd81cb81d0cd01
b32773c2cb96        amazon/amazon-ecs-agent:latest                                "/agent"                 35 minutes ago       Up 35 minutes                                 ecs-agent



잠시 후 이전 작업 정의의 작업이 중지됩니다.
[ec2-user@ip-172-31-14-134 ~]$ docker ps
CONTAINER ID        IMAGE                                                         COMMAND                  CREATED             STATUS              PORTS                     NAMES
537811dea3fd        ******.dkr.ecr.ap-northeast-1.amazonaws.com/my-nodejs   "node /src/bin/www &"    7 minutes ago       Up 7 minutes        0.0.0.0:32772->3000/tcp   ecs-p-test-node-ec2-12-my-nodejs-b8dcc0b588d5e0e67600
7baf08f94a2e        ******.dkr.ecr.ap-northeast-1.amazonaws.com/xray        "/usr/bin/xray -b 0.…"   7 minutes ago       Up 7 minutes        0.0.0.0:32772->2000/udp   ecs-p-test-node-ec2-12-xray-deamon-9ab1b4b2beb8fd919701
b32773c2cb96        amazon/amazon-ecs-agent:latest                                "/agent"                 41 minutes ago      Up 41 minutes                                 ecs-agent

약속사항



투고 내용은 개인의 의견이며, 소속 기업·부문 견해를 대표하는 것이 아닙니다.

좋은 웹페이지 즐겨찾기