코드를 컨테이너로 감싸고(참고1), AWS ECR에 컨테이너를 등록(from2)하고, 이를 세이지메이커 엔드포인트(Sagemaker Endpoint)(from1)에 배포할 수 있다. 빌드한 컨테이너를 AWS 의 ECR에 푸시(참고2)하는 간단한 셸 스크립트는 아래와 같다. git push 와 다를 것이 없다(from2).

algorithm_name=sagemaker-decision-trees # 알고리즘 이름을 작성
account=$(aws sts get-caller-identity --query Account --output text)
region=$(aws configure get region) # Get the region defined in the current configuration 
region=${region:-us-west-2} # default to us-west-2 if none defined
fullname="${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}:latest"

docker build -t ${algorithm_name} . # Build the docker image locally with the image name
docker tag ${algorithm_name} ${fullname}

AWS 의 ECR 에 푸시하기 위해 도커에 로그인할 때 유저명은 AWS 를 사용하고 비밀번호는 get-login-password 를 통해 불러온 뒤(참고5) 사용하려는 ECR 레지스트리의 URI 와 함께 사용한다(참고6).

# Get the login command from ECR and execute it directly
aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${fullname}
docker push ${fullname} # then push it to ECR with the full name.

parse me : 언젠가 이 글에 쓰이면 좋을 것 같은 재료들.

  1. 본질은 위와 같고, 저장소가 존재하지 않는 문제에 대응할 수 있는 스크립트는 아래와 같다.

    # If the repository doesn't exist in ECR, create it. (참고3)
    aws ecr describe-repositories --repository-names "${algorithm_name}" > /dev/null 2>&1
    
    # if (이전줄출력 != 0) { 
    #  ECR 생성
    #} (참고4)
    if [ $? -ne 0 ] 
    then
        aws ecr create-repository --repository-name "${algorithm_name}" > /dev/null
    fi
    

from : 과거의 어떤 생각이 이 생각을 만들었는가?

  1. a1.2.a9.1.2_1. title: 클라우드마다 존재하는 컨테이너 이미지 레지스트리 서비스는 클라우드에서 대신 구축하고 관리하는 레지스트리이다. 서비스형 컨테이너가 사용할 컨테이너 이미지를 저장할 수 있다.

supplementary : 어떤 새로운 생각이 이 문서에 작성된 생각을 뒷받침하는가?

  1. None

opposite : 어떤 새로운 생각이 이 문서에 작성된 생각과 대조되는가?

  1. None

to : 이 문서에 작성된 생각이 어떤 생각으로 발전되고 이어지는가?

  1. None