![[AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 [AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
AWS 배포를 위한 기본 세팅
https://tlseoqja.tistory.com/83
[Windows] Windows에서 jar파일을 AWS 서버에 배포하기 - (1) 배포를 위한 기본 세팅
AWS ECS 생성 먼저 서버를 배포하기 전에 AWS의 ECS (Elastic Container Service)를 생성해야 된다. 공식문서나 다른 블로그를 찾아보고 클러스터 및 서비스를 등록해주면 된다. https://docs.aws.amazon.com/ko_kr/Amaz...
tlseoqja.tistory.com
Dockerfile을 사용해 AWS에 배포하기
명령 프롬프트창을 열고 Dockerfile을 생성한 폴더로 이동한다.
아래 순서대로 명령어를 입력해서 Docker 이미지 생성 및 배포를 진행하면 된다.
1. Docker CLI 인증하기
다음의 명령어를 입력해서 기본 레지스트리에 대해 Docker CLI를 인증한다.
다음 명령어 입력 시 docker 명령이 Amazon ECR을 사용하여 이미지를 푸시하고 가져올 수 있다.
aws ecr get-login-password --region [region] | docker login --username AWS --password-stdin [aws_account_id].dkr.ecr.[region].amazonaws.com
[region]
• aws를 등록한 region 값을 넣어준다.
• 서울 서버로 생성했기 때문에 ap-northeast-2로 넣어주면 된다.
[aws_account_id]
• aws의 계정 ID를 넣어주면 된다.
• 계정 ID는 ECS의 클러스터에서 ARN 부분을 보면 12자리의 숫자로 된 부분이 계정 ID이다.
![[AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - Dockerfile을 사용해 AWS에 배포하기 - 1. Docker CLI 인증하기 [AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - Dockerfile을 사용해 AWS에 배포하기 - 1. Docker CLI 인증하기](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
2. Dockerfile에서 이미지 빌드하기
다음 명령어를 입력해서 Dockerfile에서 설정한 값으로 Docker 이미지를 빌드한다.
docker build -t [이미지명] .
3. 생성된 이미지에 태그 지정하기
docker tag [이미지명] [aws_account_id].dkr.ecr.[region].amazonaws.com/[리포지토리명]:latest
[이미지명]
• docker로 빌드한 이미지명을 넣어준다.
[리포지토리명]
• aws에서 생성한 리포지토리명을 넣어주면 된다.
• 생성된 리포지토리가 없다면 다음 명령어를 사용해서 리포지토리를 생성하면 된다.
:latest
• 리포지토리 내의 가장 최신 이미지를 가져온다.
* 리포지토리 생성
aws ecr create-repository --repository-name [리포지토리명] --region [region]
명령어 입력 시 다음과 같이 출력되면 리포지토리의 생성이 완료된 것이다.
{
"repository": {
"registryId": "aws_account_id",
"repositoryName": "리포지토리명",
"repositoryArn": "arn:aws:ecr:region:aws_account_id:repository/리포지토리명",
"createdAt": 1505337806.0,
"repositoryUri": "aws_account_id.dkr.ecr.region.amazonaws.com/리포지토리명"
}
}
4. Docker 이미지 AWS로 푸시하기
docker push [aws_account_id].dkr.ecr.[region].amazonaws.com/[리포지토리명]:latest
AWS 서비스 업데이트하기
aws 클러스터를 생성하면서 만든 서비스를 업데이트해주면 배포가 완료된다.
서비스로 들어가서 우측 상단의 '서비스 업데이트' 버튼을 눌러준다.
![[AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - AWS 서비스 업데이트하기 [AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - AWS 서비스 업데이트하기](https://blog.kakaocdn.net/dn/cdUFcF/btsGKMgtSjb/iM7Khcr1L177Rv8YeTx6u0/img.png)
화면의 '새 배포 강제적용'을 체크한 후 업데이트를 눌러주고 몇 분 기다리면 배포가 완료된다.
![[AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - AWS 서비스 업데이트하기 [AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (2) Dockerfile을 이용한 AWS 배포 - AWS 서비스 업데이트하기](https://blog.kakaocdn.net/dn/b1LK9N/btsGLCxppKD/FYogoavdUSG8etVkCEqK91/img.png)
참고 사이트
https://docs.aws.amazon.com/ko_kr/AmazonECS/latest/developerguide/create-container-image.html
Amazon ECS에서 사용할 컨테이너 이미지 생성 - Amazon Elastic Container Service
경우에 따라서는 ec2-user가 Docker 데몬에 액세스할 수 있는 권한을 제공하기 위해 인스턴스를 재부팅해야 할 수도 있습니다. 다음 오류가 표시될 경우 인스턴스를 재부팅합니다. Cannot connect to the D...
docs.aws.amazon.com
'🗄️AWS > AWS' 카테고리의 다른 글
[AWS] Failed to validate connection (0) | 2025.02.18 |
---|---|
[AWS] Data source rejected establishment of connection, message from server: "Too many connections" (0) | 2025.02.17 |
[AWS] Request method 'GET' is not supported (1) | 2025.02.04 |
[AWS] 가비아 SSL 인증서로 AWS HTTPS 등록하기 (0) | 2025.02.03 |
[AWS] Windows에서 jar파일을 AWS 서버에 배포하기 - (1) 배포를 위한 기본 세팅 (1) | 2024.04.19 |
댓글