Monday, 27 January 2020
How to push a Docker image to Amazon ECR
Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images.
In this article, you'll learn how to push your docker image to Amazon ECR.
Build your docker application
```
docker build -t hello-world .
```
Run the following command to see the image
```
docker image ls
```
```
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 3b521a2b570b 6 minutes ago 26MB
```
Before moving to the next step, make sure you have setup your aws credentials. To do that, you can run ``aws configure`` to perform your setup. The region for this demostration is ``ap-southeast-1``.
After the configuration setup, you can run the below command to verify
```
aws sts get-caller-identity
```
Retrieve the login command to use to authenticate your Docker client to your registry
```
aws ecr get-login --no-include-email --region ap-southeast-1
```
Your Docker client must authenticate before pushing and pulling images. Copy the command and run it. You should see the below message
```
Login Succeeded
```
Create an ECR repository
```
aws ecr create-repository --repository-name hello-world --region ap-southeast-1
```
```json
{
"repository": {
"repositoryArn": "arn:aws:ecr:ap-southeast-1:473625259682:repository/hello-world",
"registryId": "473625259682",
"repositoryName": "hello-world",
"repositoryUri": "473625259682.dkr.ecr.ap-southeast-1.amazonaws.com/hello-world",
"createdAt": 1576506790.0,
"imageTagMutability": "MUTABLE"
}
}
```
Tag your image
```
docker tag hello-world:latest 473625259682.dkr.ecr.ap-southeast-1.amazonaws.com/hello-world:latest
```
Push the image to the repository you just created
```
docker push 473625259682.dkr.ecr.ap-southeast-1.amazonaws.com/hello-world:latest
```
That's it. You've successfully push your image to the ECR. In the next part, you'll learn how to simplify your development to production workflow with [Amazon Elastic Container Service (ECS)](https://aws.amazon.com/ecs/).
For more about ECR, please check out the user guide [here](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html).
Subscribe to:
Post Comments (Atom)
A Fun Problem - Math
# Problem Statement JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today t...
-
SHA stands for Secure Hashing Algorithm and 2 is just a version number. SHA-2 revises the construction and the big-length of the signature f...
-
Contest Link: [https://www.e-olymp.com/en/contests/19775](https://www.e-olymp.com/en/contests/19775) Full Solution: [https://github.com/...
No comments:
Post a Comment