Pushing a Docker image to an Amazon ECR private repository
You can push your container images to an Amazon ECR repository with the docker push command.
Amazon ECR also supports creating and pushing Docker manifest lists that are used for multi-architecture images. For information, see Pushing a multi-architecture image to an Amazon ECR private repository.
To push a Docker image to an Amazon ECR repository
The Amazon ECR repository must exist before you push the image. For more information, see Creating an Amazon ECR private repository to store images.
-
Authenticate your Docker client to the Amazon ECR registry to which you intend to push your image. Authentication tokens must be obtained for each registry used, and the tokens are valid for 12 hours. For more information, see Private registry authentication in Amazon ECR.
To authenticate Docker to an Amazon ECR registry, run the aws ecr get-login-password command. When passing the authentication token to the docker login command, use the value
AWS
for the username and specify the Amazon ECR registry URI you want to authenticate to. If authenticating to multiple registries, you must repeat the command for each registry.Important
If you receive an error, install or upgrade to the latest version of the AWS CLI. For more information, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide.
aws ecr get-login-password --region
region
| docker login --username AWS --password-stdin
.dkr.ecr.aws_account_id
region
.amazonaws.com -
If your image repository doesn't exist in the registry you intend to push to yet, create it. For more information, see Creating an Amazon ECR private repository to store images.
-
Identify the local image to push. Run the docker images command to list the container images on your system.
docker images
You can identify an image with the
repository:tag
value or the image ID in the resulting command output. -
Tag your image with the Amazon ECR registry, repository, and optional image tag name combination to use. The registry format is
. The repository name should match the repository that you created for your image. If you omit the image tag, we assume that the tag isaws_account_id
.dkr.ecr.region
.amazonaws.com.rproxy.goskope.comlatest
.The following example tags a local image with the ID
e9ae3c220b23
as
.
/my-repository:tagaws_account_id
.dkr.ecr.region
.amazonaws.com.rproxy.goskope.comdocker tag
e9ae3c220b23
/aws_account_id
.dkr.ecr.region
.amazonaws.com.rproxy.goskope.commy-repository:tag
-
Push the image using the docker push command:
docker push
/aws_account_id
.dkr.ecr.region
.amazonaws.com.rproxy.goskope.commy-repository:tag
-
(Optional) Apply any additional tags to your image and push those tags to Amazon ECR by repeating StepĀ 4 and StepĀ 5.