Sub topic 1
What an ECR Registry Stores: Images, Layers, and Manifests
Prerequisites
Assume you know basic Docker commands, can build a Dockerfile, and have configured AWS CLI credentials with permission to use Amazon Elastic Container Registry (ECR).
Images, Layers, and Manifests
Amazon ECR is a managed container registry. A container image is stored as several content-addressed layers plus a manifest. Each layer contains filesystem changes, such as installed packages or application files. Identical layers can be shared by multiple images, which reduces storage and transfer costs.
The manifest is a JSON document that identifies the image configuration and its layers. A tag, such as 1.0.0, points to an image manifest. The manifest's digest is a SHA-256 identifier for its exact content.
Registries and Repositories
An ECR registry belongs to an AWS account in a Region. Its registry address includes both values:
123456789012.dkr.ecr.us-east-1.amazonaws.com
A repository is a named location inside that registry, such as my-app. Repository settings control behavior for the images stored there. For example, you can enable tag immutability and scan images when they are pushed.
The full image reference combines the registry, repository, and tag:
123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:1.0.0
Controlling Access with IAM
AWS Identity and Access Management (IAM) controls which users and roles can perform ECR actions. Push access commonly needs permissions such as ecr:PutImage, ecr:InitiateLayerUpload, and ecr:UploadLayerPart. Pull access commonly needs ecr:BatchGetImage and ecr:GetDownloadUrlForLayer.
Grant only the actions and repositories a workload needs. A build role may push to one repository, while a runtime role may only pull from it. Repository policies add resource-based controls, which are useful for sharing images with another AWS account.
Logging Docker in to ECR
Docker needs a temporary registry authorization token. The AWS CLI obtains the token, and Docker stores the resulting login credentials locally.
aws ecr get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin \
123456789012.dkr.ecr.us-east-1.amazonaws.comExercise
What does an image manifest identify?
Show answer
It identifies the image configuration and the layers needed to assemble the image.