3 Temmuz 2023 Pazartesi

aws ecr seçeneği - Container Registry

create-repository seçeneği
--repository-name ile ismi belirtilen yeni bir repository yaratılır

Örnek
Açıklaması şöyle
The container should be published to a registry. For this end, we’ll use Amazon ECR, a managed container registry to store, share, and deploy containers in the AWS Cloud.
...
Now, for each microservice container image, we need to create an ECR repository. Please note the repository name should exactly match the container image repository name.

Here’s the command to create a repository in ECR for the Order container image:
Şöyle yaparız
> aws ecr create-repository --repository-name microservice-customer
Çıktısı şöyle
{
  "repository": {
  "repositoryArn": "arn:aws:ecr:eu-central-1:877546708265:repository/microservice-customer",
  "registryId": "877546708265",
  "repositoryName": "microservice-customer",
  "repositoryUri": "877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer",
  "createdAt": "2021-03-04T00:18:33+01:00",
  "imageTagMutability": "MUTABLE",
  "imageScanningConfiguration": {
    "scanOnPush": false
  },
  "encryptionConfiguration": {
    "encryptionType": "AES256"
  }
}
Yerel image yeniden tag'lenir ve push edilir. Şöyle yaparız
> docker tag 652da8e2130b 877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer:1.0.0

> aws ecr get-login-password \
  --region eu-central-1 | \
  docker login \
    --username AWS \
    --password-stdin \
    877546708265.dkr.ecr.eu-central-1.amazonaws.com

> docker push 877546708265.dkr.ecr.eu-central-1.amazonaws.com/microservice-customer:1.0.0
delete-repository seçeneği
--repository-name ile ismi belirtilen repository silinir

Örnek
Şöyle yaparız
aws ecr delete-repository --repository-name hello-app-runner --force
get-login-password seçeneği
docker veya podman ile login olup image push etmek için şifre gerekir. Şifreyi ortamdan çekmek için bu seçenek kullanılır

Örnek - docker
Login olmak için şöyle yaparız
aws ecr get-login-password --region eu-central-1 | 
docker login 
  --username AWS 
  --password-stdin 378612673110.dkr.ecr.eu-central-1.amazonaws.com/java-demo
Örnek - podman
Şöyle yaparız
# Create an ECR repository
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
export AWS_REGION=us-east-1
aws ecr create-repository --repository-name hello-app-runner

# Authenticate with an external container registry and push the generated image
podman login --username AWS --password $(aws ecr get-login-password \
     --region ${AWS_REGION}) ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com
podman tag hello-app-runner:latest \
  ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/hello-app-runner:latest

Hiç yorum yok:

Yorum Gönder