Containers on AWS — Amazon Elastic Container Registry (ECR) and AWS App Runner
Tags: aws, cloud, containers, containerapps
Published: 2023-03-13 06:11:53

![Architecture](https://cdn-images-1.medium.com/max/2000/1*AB1xa_rGgiD3c_jwrFgUkw.png)

Hello before, I am Budi. I write about **AWS App Runner** with **Amazon ECR** services. If you want to read about AWS App Runner with GitHub, you can see the [page](https://dev.to/budionosan/containers-on-aws-aws-app-runner-4gll). [Amazon ECR](https://aws.amazon.com/ecr/) is an AWS service that fully managed container registry that can store, share and deploy your containers.

Let’s go! Before starting, (optional) you can use [AWS Cloud9](https://aws.amazon.com/cloud9/) by Amazon EC2 for IDE.

Go to AWS Cloud9 and click **Create environment**.

![AWS Cloud9](https://cdn-images-1.medium.com/max/2000/1*h8iE3trmtvRhADGDdu15Sw.jpeg)

Then, fill in the name and description, click **Next step**.

![](https://cdn-images-1.medium.com/max/2000/1*8Kvdtr-ZSH3OXI80vDiANQ.jpeg)

Choose environment type and also instance type for IDE.

![](https://cdn-images-1.medium.com/max/2000/1*Yd-tqyhztz718JWiUolILA.jpeg)

Choose platform, cost-saving setting. Create IAM role for AWS Cloud9 and click **Next step**.

![](https://cdn-images-1.medium.com/max/2000/1*azLrwoGm20s2OelOCTsKaQ.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*de6BOYxWpQ5CudAjIXqbAg.jpeg)

Then, you can check again before click create environment for IDE. If already, can click **Create environment**.

![](https://cdn-images-1.medium.com/max/2000/1*pO6D9Z-qFRulYtqF0F2xiQ.jpeg)

![LOADING FOR CLOUD9 ENVIRONMENT](https://cdn-images-1.medium.com/max/2000/1*RfaUkKsWsbWUfMhB4UefSA.jpeg)

Then go to Amazon ECR service. Click private for private repository and click **Create repository**.

![](https://cdn-images-1.medium.com/max/2634/1*76Pc0CbQmybubO-G2QzEtg.jpeg)

Fill in the repository name and click **Create repository**.

![](https://cdn-images-1.medium.com/max/2000/1*nMkkr14KJLpiHgWUMVPrGA.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*FkMmLjdVZRVlCHKSYSUgeA.jpeg)

Now my Amazon ECR has one private repository and now can store Docker image. Go to AWS Cloud9 and the environment is ready to deploy the Docker image to Amazon ECR.

![CLICK BULLET AND CLICK VIEW PUSH COMMANDS](https://cdn-images-1.medium.com/max/2144/1*MlLikkE_HgBNx_UupY6M1A.jpeg)

Before push commands for the private repo, **git clone from GitHub** for can store/deploy image. Then click **view push commands** to see the step push Docker image to firstecr repository. Copy command number 1 until 4.

    git clone https://github.com/budionosan/serverlesshackathon.git

    cd serverlesshackathon

    aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <YOUR_AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com

    docker build -t firstecr .

    docker tag firstecr:latest <YOUR_AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/firstecr:latest

    docker push <YOUR_AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/firstecr:latest

![VIEW PUSH COMMANDS](https://cdn-images-1.medium.com/max/2000/1*PSQEmLVtqAqmaGAwD7bzXg.jpeg)

![Step 1](https://cdn-images-1.medium.com/max/2560/1*grtJe5_BwsV3RnJJfW5kbg.jpeg)

![Step 2](https://cdn-images-1.medium.com/max/2052/1*5btq-yGAu6EHV7EsC50-qw.jpeg)

After the process is finished, the image is successful push and can use for **Amazon ECS** (next tutorial), **Amazon EKS** (next tutorial) and **AWS App Runner** (this tutorial).

![](https://cdn-images-1.medium.com/max/2076/1*DMHTkgmJy0WmZCgbya3Wfg.jpeg)

Next, go to AWS App Runner service and click **create service**.

![AWS App Runner](https://cdn-images-1.medium.com/max/2000/1*V5Zc01ihjTHp_1-i6vPyWQ.jpeg)

Choose container registry, choose Amazon ECR (not Amazon ECR Public) and browse container image URL from Amazon ECR.

![](https://cdn-images-1.medium.com/max/2154/1*tk76Ucxtk8F9V0HFsfUupQ.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*XuSK713Fl7CXYMIytm-Z_g.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*sEdVq91j3QabPF4bAcazCw.jpeg)

![Container image URL.](https://cdn-images-1.medium.com/max/2000/1*x13vktOvRYLjexVAZ_r3Bg.jpeg)

You can choose deployment settings. Manual using App Runner console or CLI. Automatic means when Amazon ECR has a new version can automatically deploy to AWS App Runner. Create also IAM role for App Runner and click **Next**.

![](https://cdn-images-1.medium.com/max/2000/1*_rQ5q_ZdIzQBkLN4risSng.jpeg)

Fill in the service name, virtual CPU and memory, port (8080)

![](https://cdn-images-1.medium.com/max/2000/1*04rngCjlmv2u5DXo788Zgw.jpeg)

![THIS OPTIONAL (CAN EDITED)](https://cdn-images-1.medium.com/max/2000/1*6MG1hbZx8fc4ZO4IwRGyJg.jpeg)

![CLICK NEXT](https://cdn-images-1.medium.com/max/2000/1*DORzmvfyIFJdWq8-HyNDsg.jpeg)

You can review scrolling to bottom and click **Create & deploy** if matching.

![](https://cdn-images-1.medium.com/max/2212/1*v6t9iWHwFMwp3mbIqQ4uig.jpeg)

![](https://cdn-images-1.medium.com/max/2000/1*ht-iKo13fEkP9Yuz0VaU9A.jpeg)

Wait for loading the progress in AWS App Runner. This service has a default domain and source from Amazon ECR. The domain can be changed.

![PROGRESS](https://cdn-images-1.medium.com/max/2524/1*s26i2Cm51MmB4xeUgSC0mw.jpeg)

After the progress is finished, your App Runner service is ready. Click **default domain**.

![SUCCESSFUL](https://cdn-images-1.medium.com/max/2504/1*0hO15JbERAWBsOmWPd5LHA.jpeg)

![](https://cdn-images-1.medium.com/max/2700/1*ChK5getzlUPvJxnld-SIFA.jpeg)

![LEFT — Web application from ECR image | RIGHT — Event log.](https://cdn-images-1.medium.com/max/2392/1*QEOthhD2PPABsbAQa8sIPg.jpeg)

Services:
- **AWS App Runner** — [https://aws.amazon.com/apprunner](https://aws.amazon.com/apprunner/)
- **Amazon ECR**— [https://aws.amazon.com/ecr](https://aws.amazon.com/ecr/) 
- **Cloud9** (use Amazon EC2 resource) — [https://aws.amazon.com/cloud9](https://aws.amazon.com/cloud9/)

Create web application with App Runner are easy. Thank you very much :)