ECR + AWS App Runner: Step by Step
1. Prerequisite
Make sure you have Docker Desktop installed.
Warning
The
homebrew
version ofdocker-compose
requiresvirtualbox
, and will not work on Apple Silicon computers.
Ensure aws-cli
is installed and configured
You’ll need your account_key_id
& secret_access_key
from the AWS console.
Log docker client into AWS ECR with aws ecr get-login-password --region __region__ | docker login --username AWS --password-stdin __aws_account_id__.dkr.ecr.__region__.amazonaws.com
For example:
2. Set up ECR
Create your private repository for your project in the AWS console, and note down the repository_name
.
3. Build Your Application
Build the Docker image.
Use docker images
to find the tag of the newly built image. Referred to as __IMAGE ID__
henceforth.
Tag the local Docker image with the ECR repository name & tags using: docker tag __IMAGE ID__ __aws_account_id__.dkr.ecr._region_.amazonaws.com/__repository_name__:__tag__
For example:
4. Push Dockerised Application to ECR Repository
Push the images to ECR using docker push __repository__:__tag__
Verify that the docker image is pushed to ECR from the AWS console
5. Run Application w/ App Runner
Head to the App Runner Console once the Docker image is up in ECR. Make sure you choose the same region as the ECR. You should be able to find the image from the dropdown if you have selected the same AWS region.
Following the Creating App Runner Service step-by-step guide.
Local Development with docker compose
Troubleshooting
AWS ECS/ECS exec /usr/local/bin/docker-entrypoint.sh: exec format error
If you build your docker image on an Apple M1/M2 machine, this error may occur. To fix the issue, use:
Private
-----BEGIN PGP MESSAGE-----
hQIOAxdwc3QWykEfEAgAjGjXJq30tjZAPrHjt4N3bEt2xXNQv14l5N3RSc2rGf8V
oFJ2Nrekm1cQmv219LDw8QtsBElyYw8xc4i5LUvzszc2tjHV+EBsbtk10gAseN++
sBAA1yxdytUISvzkj5PVcROKsY4Opu16hwoTO+JYvwUL9Z7m7MTubDgeU1Zna5Lf
xB+axolS4ydCpboIDNRAGlhn0lhFc57fOpjRcJ5zzvruxKdvbrunn1nXfArA3faW
ZdKKK21RJcq6Sr2D1Ca+0VbNZI0hhr/6xsZqKnEnR4ke9YJVhZPa8hOcQnDQUibb
KAsCZeVZitIZyseeWoHPFj3oiwUoGPQ41zmhsNG8ZQgAuFCY0XK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