Welcome back!
In our last lesson, you became a Kubernetes detective, learning how to systematically debug pod startup issues using kubectl describe and kubectl logs. This is a critical operational skill that separates junior and senior engineers. We now have our services running on EKS, but the deployment process is still manual and error-prone.
Today, we take the first and most crucial step toward automating our deployment workflow. This lesson begins our module on CI/CD with GitHub Actions, where we'll build a pipeline to automatically test, build, and deploy our services.
Our learning outcome for this session is to set up an AWS ECR repository to store Docker images. This repository will serve as the central, authoritative source for the container images that our EKS cluster will pull from.
From Local Docker to a Central Registry
In your MERN stack experience, you've likely used Docker Hub to pull public images (like node or mongo) and perhaps to store your own public or private images. AWS Elastic Container Registry (ECR) serves the same fundamental purpose—it's a managed Docker container registry. However, its real power comes from its deep integration with the AWS ecosystem.

Why ECR? Comparing it to Docker Hub
Choosing a container registry is an important architectural decision. While Docker Hub is the default for many, ECR is the standard for applications built on AWS. Here’s a breakdown of the key differences, which is a common topic in backend engineering interviews.
To understand the purpose of ECR and how it compares to Docker Hub, let's watch the first few minutes of this tutorial.
AWS ECR Tutorial | Elastic Container Registry | Hands-On | Push docker image to AWS ECR
The video 'AWS ECR Tutorial' provides an excellent introduction to what ECR is and why you would choose it over a more general-purpose registry like Docker Hub.
Watch from the beginning to 08:22. Focus on: What ECR is: A fully managed Docker container registry. Key Differences vs. Docker Hub: Pay close attention to the comparison points: Access Control (IAM), AWS Integration, Security (vulnerability scanning), and Cost Structure. This explains the 'why' behind using ECR in our project.
The key takeaway is that by using ECR, we leverage AWS's robust IAM for security and benefit from low-latency, high-bandwidth connections between our registry and our EKS cluster, as they both live inside the AWS network.
Hands-On: Setting Up Your First ECR Repository
Now, let's get practical. We will create a repository for our blog-service, configure access, and push our first image manually. These are the exact steps our future CI/CD pipeline will automate.
The video you just watched continues with a full hands-on demonstration. We will follow its steps closely.
AWS ECR Tutorial | Elastic Container Registry | Hands-On | Push docker image to AWS ECR
Let's continue with the same video, 'AWS ECR Tutorial', to walk through the entire process of creating a repository and pushing an image.
Follow the demonstration from 08:22 to 24:12. I've broken down the key stages below. Perform these steps on your own AWS account as you watch. Create Repository (08:22 - 11:26): Navigate to the ECR service in the AWS Console and create a new private repository. Name it blog-service. Configure AWS CLI & IAM (11:26 - 19:29): The video shows how to install the AWS CLI and create an IAM user with programmatic access. For permissions, attach the AmazonEC2ContainerRegistryFullAccess policy for now. Then, run aws configure in your terminal to set up your access keys. Authenticate, Build, Tag, Push (19:29 - 24:12): This is the core workflow. The presenter uses the 'View push commands' button in the ECR console—this is a fantastic way to learn. Follow these four commands precisely for your blog-service project.
Let's break down that final four-command sequence, as it's the heart of the process:
1. Authenticate Docker with ECR
This command retrieves a temporary authentication token from AWS and pipes it into the docker login command.
aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com
You should see a "Login Succeeded" message. If not, double-check your AWS CLI configuration and IAM permissions.
2. Build your Docker image
Navigate to your blog-service directory (where its Dockerfile is) and build the image.
docker build -t blog-service .
3. Tag the image for ECR
Docker uses tags to know where to push an image. You need to tag your locally built image with the full ECR repository URI.
docker tag blog-service:latest <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/blog-service:latest
The format is <registry>/<repository>:<tag>. This is a common point for typos, so be careful.
4. Push the image
Finally, push the tagged image to ECR.
docker push <your-aws-account-id>.dkr.ecr.<your-region>.amazonaws.com/blog-service:latest
After the push completes, refresh your ECR repository page in the AWS console. You should now see your blog-service image listed with the latest tag.

Your Task: Create Repositories for All Services
You have successfully pushed the blog-service image. To prepare for our CI/CD pipeline, repeat the process for our other two services:
- Create ECR Repositories: In the AWS Console, create private ECR repositories named
auth-serviceandapi-gateway. - Build, Tag, and Push: For both the
auth-serviceandapi-gatewayprojects, run thedocker build,docker tag, anddocker pushcommands to upload their images to their respective repositories.
Common Bugs & Fixes:
denied: User ... is not authorized to perform: ecr:CreateRepository: Your IAM user is missing permissions. Ensure theAmazonEC2ContainerRegistryFullAccesspolicy is attached.An error occurred (RepositoryNotFoundException) when calling the Push...: The repository name in yourdocker pushcommand doesn't exactly match the one you created in ECR.- Login fails or
Error: Cannot perform an interactive login from a non-TTY device: You might be using an older, deprecatedaws ecr get-logincommand. Ensure you use theget-login-passwordcommand as shown above.
Conclusion
Congratulations! You have successfully set up AWS ECR and manually pushed the Docker images for all three of our backend services. You've established the central image registry that is essential for automated, scalable deployments on AWS.
Key Takeaways:
- ECR is AWS's native container registry, offering tight integration with IAM for security and EKS for deployments.
- The workflow to push an image involves authenticating the Docker client, building the image, tagging it with the full ECR URI, and pushing it.
- Each of these manual CLI commands directly corresponds to a step we will automate in our CI/CD pipeline.
Preview of the Next Lesson:
With our image registry in place, we are ready to start building our pipeline. In the next lesson, you will create a GitHub Actions workflow that automatically runs tests and lint checks on every push. We will lay the foundation of our CI file, configure triggers, and take the first step in moving from manual commands to a fully automated, professional workflow.