DEV Community

Cover image for Day 5: AWS ECR: Creating and Managing Container Registries
Pragnesh Patel
Pragnesh Patel

Posted on

Day 5: AWS ECR: Creating and Managing Container Registries

Continuing from Day 4, today we explore Amazon Elastic Container Registry (ECR), AWS's managed Docker registry. We'll create a repo and manage it.

Why ECR?

ECR stores Docker images securely, integrates with ECS, and handles authentication automatically.

Step 1: Create an ECR Repository

Via Console:

  1. Search for ECR in AWS Console.
  2. Click "Create repository."
  3. Choose private/public, name it (e.g., my-app-repo).
  4. Create.

Via CLI:

aws ecr create-repository --repository-name my-app-repo --region us-west-2
Enter fullscreen mode Exit fullscreen mode

Step 2: Managing Repositories

  • Public vs. Private: Private for internal use; public for sharing.
  • Lifecycle Policies: To clean old images, add policy via console (e.g., expire untagged images after 30 days).
{
  "rules": [
    {
      "rulePriority": 1,
      "description": "Expire untagged images",
      "selection": {
        "tagStatus": "untagged",
        "countType": "sinceImagePushed",
        "countUnit": "days",
        "countNumber": 30
      },
      "action": { "type": "expire" }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Verify: aws ecr describe-repositories

Today’s Takeaway

ECR is set up! Tomorrow, push images to it.

What’s Next?
In Day 6, we’ll integrate Docker with ECR.

Top comments (0)