Member-only story
How To Push a Docker Image to Amazon ECR With Jenkins
Create and configure an AWS and push it using Jenkins
A year ago, my website was running on Heroku. Because Heroku does not allow multiple applications on the same instance, I had to pay $7 twice each month (backend and frontend application). For each additional application, this would cost me another $7 per month.
I was convinced that on-premise would be a lot cheaper, so I took an old laptop and installed everything. After configuring Linux and docker-compose, amongst other things, my website was finally up and running again. This allowed me to save $14 every month.
Until problems arose. Problems you don’t really expect to happen. Problems you might encounter as well:
- Power failures
- Broken WiFi connection
- Configuration issues
Therefore, out of necessity, the only option available was to go back to the cloud for improved stability. But this time, it would be a different cloud provider than Heroku. Pushing my Docker images to the cloud is the first part of this solution. And this is what this article is all about: Pushing Docker images to a cloud repository like Amazon AWS ECR.
Let me make you a promise: This article is only going to take a few minutes of your time. We’ll handle three steps to deploy to ECR:
- Create an AWS ECR repository.
- Configure AWS credentials in Jenkins.
- Create a build step to push with Jenkins.
Create an AWS ECR Repository
The first step is easy: All you have to do is log into the AWS developer console and go to your AWS service Elastic Container Registry (AWS ECR).
In this service, you create a Docker container repository, as you’ll see in the screenshot provided. You don’t have to worry about leaving all the default settings on. They have no hidden costs.
The only field you need to fill in is the “docker repository name.” Choose a name like “website-frontend” or something more suited for your application. Click on “Create repository,” and you’ll have a repository to push Docker images towards.