First steps with Amazon EC2 Container Service (101) — ECR

Docker is a technology that has been doing a huge echo in the IT field since the past few years.

docker-vs-aws on google search
docker-vs-aws on google search

All major public clouds (Amazon Web Service, Google Cloud, Microsoft Azure) offer a more or less integrated solution for container management. In these posts we will explain how to start successfully on the managed service Amazon EC2 Container Service.

This serie suppose that you already have created a VPC where the host instances for the docker containers will be created, that the AWS CLI is installed on your computer and we are going to use the “Hello-world” image (dockercloud/hello-world) available on the docker hub.

1 — Creation of a Docker private repository

To be deployed , a container image must be available in a docker repository. There is multiple solution that can be used , Amazon Web services (AWS) proposes a private managed repository (ECR) at an interesting price (0,1$/GB/month on 01/08/2017).

To deploy our image on the ECR (Amazon EC2 Container Registry) we will start by pulling this image from the docker hub.

docker pull dockercloud/hello-world

Now we have our image, we will push it on ECR
 Then, we will connect to the AWS web console for ecs

1a — if you still haven’t use the service yet

You will find yourself on the “Get started” page, you just have to push 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 so the ECS demo (sample) will not be deployed

getstarted

1b — If you have already used ECS

You just have to go to “Repositories” then click on “Create Repository”

2 — On the next page

You will be able to give a name to your repository , helloworld on our case. Then you can click on “Next step” button

ecr-name

3 — The final page

It will give us all the information needed to use the created repository.

2 — Add an image to ECR

We are going to push our HelloWorld image to the repository. To do that we are going to connect on 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 commande 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

Now we are connected, we are able the push our 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 on the AWS web console , you will be able to see our image in the repository

ecr-push

In the next post we are going to use this image to launch a docker container on ECS.

See you soon

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.