본문 바로가기
도커

Docker AWS SpringBoot ECR 배포하기

by 2세1의 행복한 개발 2021. 9. 7.
반응형

Dockerfile

FROM amazoncorretto:11
ARG JAR_FILE=target/*.war
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

JAR_FILE 쪽에 사용하시는 부트 설정에 따라 war, jar를 바꿔주셔야합니다

pom.xml 위치에 있어야합니다

docker up
docker build -t foo/bar .
docker run -d -p 80:80 foo/bar

AWS-CLI 로그인

aws configure

AWS ECR 배포

aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
docker push 828.ecr.ap-northeast-2.amazonaws.com/foo/bar:latest

 

권한 오류

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam:: is not authorized to perform: ecr:GetAuthorizationToken on resource: *
Error: Cannot perform an interactive login from a non TTY device

aws 권한 부여

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ListImagesInRepository",
            "Effect": "Allow",
            "Action": [
                "ecr:ListImages"
            ],
            "Resource": "arn:aws:ecr:ap-northeast-2:123456789000:repository/*"
        },
        {
            "Sid": "GetAuthorizationToken",
            "Effect": "Allow",
            "Action": [
                "ecr:GetAuthorizationToken"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ManageRepositoryContents",
            "Effect": "Allow",
            "Action": [
                "ecr:GetAuthorizationToken",
                "ecr:BatchCheckLayerAvailability",
                "ecr:GetDownloadUrlForLayer",
                "ecr:GetRepositoryPolicy",
                "ecr:DescribeRepositories",
                "ecr:ListImages",
                "ecr:DescribeImages",
                "ecr:BatchGetImage",
                "ecr:InitiateLayerUpload",
                "ecr:UploadLayerPart",
                "ecr:CompleteLayerUpload",
                "ecr:PutImage"
            ],
            "Resource": "arn:aws:ecr:ap-northeast-2:123456789000:repository/*"
        }
    ]
}

권한 오류 2

is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr

두곳을 내 repository로 바꿔야함

 

댓글