AWS ECS Fargate 컨테이너 접속 방법

백종현·2024년 9월 13일
0

평범한 케이스에서는 ECS Fargate에 접속하지 않는것이 Best Case이지만, ECS Fargate에서 실행 중인 컨테이너에 접속해야하는 경우가 있으므로 작성해보았다.

  1. 서비스 업데이트
aws ecs update-service --cluster <cluster-name> --service <service-name> --enable-execute-command
  1. 작업(Task) 재시작
    서비스가 업데이트된 후, 변경사항을 적용하기 위해 관련 작업(Task)를 재시작
  • 참고) --force-new-deployment 옵션을 넣게 되면, 새로 배포하게 된다.
aws ecs update-service --cluster <cluster-name> --service <service-name> --force-new-deployment

2-1. 아래 명령어를 통해 잘 적용이 됐는지 확인한다.

aws ecs describe-tasks --cluster <cluster-name> --tasks <task-arn> | grep enable

위 명령어 결과가 "enableExecuteCommand": true 로 반드시 떠야 대상 task에 접속이 가능하다.

  1. 컨테이너에 접속
    아래 명령어를 사용하여 컨테이너에 접속
aws ecs execute-command --cluster <cluster-name> --task <task-arn> --container <container-name> --command "/bin/bash" --interactive
예시) aws ecs execute-command --cluster UltimaF --task 838d773b17954bcfbbacf343fb4fea70 --container ultima --interactive --command "/bin/sh"
profile
노력하는 사람

0개의 댓글

관련 채용 정보