Getting Started with Amazon EC2 Container Service (101) – ECR
- Published on
- Authors

- Name
- Sylvain BRUAS
- @sylvain_bruas
Docker is a technology that has been making waves in the IT world for several years now.
All major public clouds (Amazon Web Services, Google Cloud, Microsoft Azure) offer a more or less integrated solution for container management. In this series of articles, we explain how to successfully get started with the managed Amazon EC2 Container Service.
This series assumes that you have created an Amazon Virtual Private Cloud (VPC) where the host instances for Docker containers will be created, that the AWS CLI is installed on your machine, and we will use a "Hello-world" image (dockercloud/hello-world) available on Docker Hub.
1 - Creating a Private Docker Repository (ECR)
To be deployed, a container image must be made available in a Docker repository. Several solutions are available. Amazon Web Services (AWS) offers a managed private repository (ECR) at an attractive price (US$0.1/GB/month as of 01/08/2017).
To deploy our image on ECR (Amazon EC2 Container Registry), we will first pull this image from Docker Hub.
docker pull dockercloud/hello-world
Now that we have our image, we will push it to ECR. Let's connect to the AWS web console for ECS.
1.1a – If you haven't used the service yet
You will land on the "Get Started" page. Simply click the blue "Get Started" button in the middle of the page. On the next screen (Getting Started with Amazon EC2 Container Service), uncheck the box to skip deploying the Amazon Elastic Container Service (ECS) demo (sample).
1.1b – If you have already used ECS
Simply click on Repositories then on "Create Repository".
1.2 – On the next page
You can name your repository — helloworld in our case. Then proceed to the next step (Next step).
1.3 – The last page
It provides all the instructions for using the newly created repository.
2 – Pushing an Image to ECR
We will push our HelloWorld image to the repository. To do this, we will log in to ECR from our machine (our repository is in Ireland).
aws ecr get-login --no-include-email --region eu-west-1
docker login -u AWS -p eyJwRXl…...iMSIsZnR5cGUKOiJEQWRBX0tFWSJ8 https://123456789012.dkr.ecr.eu-west-1.amazonaws.com
We get a command line that will allow us to connect to ECR.
docker login -u AWS -p eyJwRXl…...iMSIsZnR5cGUKOiJEQWRBX0tFWSJ8 https://123456789012.dkr.ecr.eu-west-1.amazonaws.com
Login Succeeded
We are now connected and can push the local image.
docker tag dockercloud/hello-world:latest 123456789012.dkr.ecr.eu-west-1.amazonaws.com/helloworld:latest
docker push 123456789012.dkr.ecr.eu-west-1.amazonaws.com/helloworld:latest
If you connect to the AWS web console, you will be able to see your image in the repository.
In the next article, we will use this image to launch a Docker container on ECS.





