đ How to Push a Docker Image to AWS EKS Without a Pipeline or Docker Hub
No pipeline? No Docker Hub? No problem! Here's how to push your Docker images to AWS EKS using just ECR and your terminal.
Introduction
Ever been stuck trying to get a Docker image into AWS EKS, but didnât want to mess around with a full CI/CD pipeline or push to Docker Hub?
Iâve been there. Sometimes you just want to quickly deploy an app without all the overhead. Whether youâre testing something in a dev environment or just donât want to deal with extra tools, this simple method will help you push a Docker image directly to AWS EKS using Amazon ECRâand skip the middleman.
In this post, Iâll walk you through the process of deploying your containerized app to EKS without any external dependencies. Ready? Letâs jump in!
đŻ Why Use This Method?
This is perfect if:
Youâre working on a dev or test environment and donât need the complexity of a full CI/CD pipeline.
You want to keep everything within AWS (no external registries like Docker Hub).
Youâre under strict security policies that donât allow external registries.
With ECR and EKS, you can keep things clean, quick, and all within AWS.
đ§° What Youâll Need
Before we dive into the steps, letâs make sure youâve got everything set up:
â AWS CLI installed and configured (
aws configure
)â Docker running locally
â kubectl configured for your EKS cluster
â IAM permissions for ECR and EKS
â An existing EKS cluster
đ ď¸ Step-by-Step: Push a Local Docker Image to EKS
1. Create an ECR Repository
Letâs start by creating a repository in Amazon ECR. This is where weâll store your Docker image.
Run this command:
aws ecr create-repository --repository-name my-app --region <your-region>
Itâll return a URL for your new repository, something like:
<account-id>.dkr.ecr.<region>.amazonaws.com/my-app
Keep that URL handyâitâs where your Docker image will live!
2. Authenticate Docker with ECR
To push images to ECR, we need Docker to authenticate first. AWS CLI makes it easy with a simple command:
aws ecr get-login-password --region <your-region> | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com
If it says
Login Succeeded
, youâre ready to go!
3. Build and Tag Your Docker Image
Now, letâs build your Docker image. If you have a Dockerfile ready, you can run this command:
docker build -t my-app .
Once itâs built, tag the image with the ECR repository URI:
docker tag my-app:latest <account-id>.dkr.ecr.<region>.amazonaws.com/my-app:latest
Pro Tip: In production, skip
latest
and use version tags likev1.0.0
. Itâs way easier to keep track of whatâs deployed.
4. Push the Image to ECR
Time to push the image to ECR:
docker push <account-id>.dkr.ecr.<region>.amazonaws.com/my-app:latest
Youâll see Docker uploading your image. Once itâs done, your image is now in ECR, ready for EKS to use!
5. Write Your Kubernetes Deployment File
Now, we need to tell EKS how to run your app. This is where the deployment.yaml file comes in. Create a new file called
deployment.yaml
and paste this in:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: <account-id>.dkr.ecr.<region>.amazonaws.com/my-app:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 80
type: ClusterIP
Donât forget to replace
<account-id>
and<region>
with your actual values.
6. Connect kubectl to Your EKS Cluster
Next, weâll connect
kubectl
to your EKS cluster:
aws eks update-kubeconfig --region <your-region> --name <cluster-name>
Now, deploy your app to EKS:
kubectl apply -f deployment.yaml
7. Verify Everythingâs Running
Letâs check if everythingâs up and running:
kubectl get deployments
kubectl get pods
If everythingâs working fine, youâll see your app running in the cluster.
Want to expose it to the outside world? You can do that by adding a LoadBalancer or an Ingress resource to your Kubernetes YAML.
â
Best Practices & Tips
đ IAM Permissions: Make sure your EKS worker nodes have the
AmazonEC2ContainerRegistryReadOnly
policy so they can pull images from ECR.đˇ Version Tags: Avoid using
latest
for production images. Instead, use a version tag likev1.0.0
âit makes rollbacks and updates easier.đĄď¸ Security: Enable ECRâs built-in vulnerability scanning to make sure your images are secure.
đ§š Cleanup: If you have unused repositories or images, delete them to save costs:
aws ecr delete-repository --repository-name my-app --region <your-region> --force
đŹ Why I Love This Approach
Honestly, I love this method because it keeps things simple. A while ago, I was working on a quick internal project. I didnât want to set up a complicated CI/CD pipeline, and I wasnât ready to push to Docker Hub.
So, I just ran the commands to push my image to ECR, deployed it to EKS, and boomâit was up and running in no time. This approach saved me hours, and it was perfect for a dev/test scenario.
đ Related Posts You Might Like
đ Track & Improve Your Process
Once youâve deployed your app, donât forget to:
â Use Google Analytics to track page views and clicks
â Test on mobile to ensure your YAMLs and code blocks look good
â Invite feedback and iterate on the post if you get helpful comments
đ§ Wrapping Up
Deploying Docker images to EKS without a pipeline is straightforward, and itâs a great solution for testing or quick deployments. By using Amazon ECR and EKS, you keep everything within AWS, saving you time and effort.
If you need more complex setups, consider adding CI/CD or exploring more advanced Kubernetes features like auto-scaling and Ingress. But for now, this simple approach should get your app running quickly!
đŁ Share the Love
If you found this helpful, share it with your network!
âSkip the pipeline! đ Deploy Docker images straight from your laptop to AWS EKS with no Docker Hub or CI/CD. #EKS #DevOps #AWS #Docker #CodingTipsâ
đ Got questions or want to share your workflow?
Drop a comment belowâIâd love to hear how youâre deploying to EKS!
#Docker #AWSEKS #AmazonEKS #Containerization #Kubernetes #AWS #ECR #DockerImage #CloudComputing #DevOps #TechBlog #SoftwareDevelopment #AWSCloud #ContainerOrchestration #EKSDeployment
Docker image to AWS EKS, push Docker image to EKS, AWS EKS deployment, Docker ECR EKS tutorial, deploy container to AWS EKS, AWS Elastic Kubernetes Service guide, Docker container on EKS, AWS ECR Docker image, Kubernetes deployment AWS, EKS without pipeline, Docker to AWS tutorial, containerization AWS EKS, EKS setup guide, AWS DevOps tutorial, manage Docker images AWS