Getting started with Container registry
Create a repository, log in with docker, push an image, read its scan, and delete it all again.
You need Docker on a Linux or macOS machine and an image to push. Replace
org-example1234.ecr.example.com with your registry host (the console shows it as
Image URI on the repository's page) and my-app with the repository name. In the CLI
steps, repository-id is the id the create command answers with, and
manifest-id is the image's manifest.id in the image list.
Prerequisites
ecr:CreateRepository,ecr:GetAuthorizationToken,ecr:PushImage,ecr:PullImage,ecr:DescribeRepositories,ecr:ListImages,ecr:GetScanResultsandecr:DeleteRepository. TheAdministratorAccesspolicy has all of them.
Step 1: Create a repository
- Open Container registry, then choose Create image repository.
- For Repository name, enter my-app.
- Choose Create image repository.
The repository's page opens on its Images tab.
dcloud ecr repositories create --name my-appStep 2: Log in
- On the repository's page, open the Push commands tab.
- Choose Generate a login token.
- Run the
docker logincommand it shows, and paste the token at thePassword:prompt.
dcloud ecr auth login-tokenRun docker login org-example1234.ecr.example.com -u token and paste the token from
the answer at the Password: prompt.
Step 3: Push and pull
docker tag my-image:latest org-example1234.ecr.example.com/my-app:v1.2.0
docker push org-example1234.ecr.example.com/my-app:v1.2.0
docker pull org-example1234.ecr.example.com/my-app:v1.2.0You pay for the stored layers from now on.
Step 4: Read the scan
A pushed image is scanned on its own.
- Open the Images tab. The Vulnerabilities column shows Scanning while the scan runs, then the worst severity found or Clean.
- Choose the result to open the scan report.
dcloud ecr images list repository-id
dcloud ecr images latest-scan repository-id manifest-idmanifest.id of the image's row is the manifest id.
Clean up
Deleting the repository deletes its images.
- On the repository's page, open the Danger zone tab.
- Choose Delete repository, type the repository's name, then choose Delete repository.
dcloud ecr repositories delete repository-id