<5> AWS ECR에 docker 이미지 올리기 2 (선택) 1 현재 AWS Account id를 변수로 등록 ? export ACCOUNT_ID=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.accountId') echo "export ACCOUNT_ID=${ACCOUNT_ID}" | tee -a ~/.bash_profile 현재 리전을 디폴트로 설정 ? export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region') echo "export AWS_REGION=${AWS_REGION}" | tee -a ~/.bash_profile aws configure set default.region ${AWS_REGION} 2 docker images REPOSITORY TAG IMAGE ID CREATED SIZE test-image latest 86a04572f50c 10 seconds ago 133MB demo2 latest 6dca039085a0 26 minutes ago 60.7MB demo-flask-backend latest 53d888792869 About an hour 198MB hello-world latest 53d888792869 About an hour ago 198MB 3 ECR 만들기 ? hello-repository aws ecr create-repository --repository-name hello-repository --region ${AWS_REGION} 4 도커 이미지에 태그 설정하기 - 구분하기 위해 태그 사용한다. ? docker tag hello-world $ACCOUNT_ID.dkr.ecr.${AWS_REGION}.amazonaws.com/hello-repository 5 인증 토큰을 가져오고 , docker login으로 전달해 로그인 aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.${AWS_REGION}.amazonaws.com // 리전을 맞게 설정해야 한다. aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.us-west-1.amazonaws.com 6 리파지토리에 이미지 올리기 docker push $ACCOUNT_ID.dkr.ecr.${AWS_REGION}.amazonaws.com/hello-repository 0f8104f52693: Pushed 678e235885f7: Pushed 67826a8274f7: Pushed 6babb56be259: Pushed