Managing container images for cloud deployment
Docker image is like a process template that we run to instantiate our containers. You probably heard of Docker Hub, a public registry that stores Docker images. While we can deploy Docker images from Docker Hub on AWS, we will explore the Amazon Elastic Container Registry (ECR) to store our customized Docker image.
You can create a free account with the AWS free tier to explore this feature. It is necessary to have the following installed on your workstation:
Configuring AWS CLI
To set up your AWS CLI, you need to run the “aws configure” command in your command prompt. This will prompt you for the below information:
- Access Key ID
- Secret access key
- AWS Region — identifies the AWS Region whose servers you want to send your requests to by default
- Output format — how results are formatted. Possible values are json (default), yaml, yaml-stream, text and table.
Your AWS administrator would have provided you with the Access key ID and secret access key. Otherwise, you can create the access key under the Security credentials tab under your IAM user profile.
Pushing customized Docker image to Amazon ECR
Assuming you have configured your AWS CLI with your AWS access key ID and secret access key, you can push your custom image onto the Amazon ECR.
Follow the steps below to do so:
1 — Search for ECR under AWS services.
2 — Create a repository under the Amazon ECR. In our example, we keep the repository private and name the repository “Atoti”.
3 — Select the repository created and click on “View push commands”.
4 — Follow the push commands on the AWS CLI to push the image.
You can access the image on AWS with the image URI highlighted below:
With the image URI, you can deploy the image container anywhere on AWS. For instance, we can define our Docker image in the Task definition of Amazon Elastic Container Service (ECS) using the image URI from our repository in Amazon ECR:
You might also be interested in…
In case you would like to try customizing a Docker image, check out our previous article — A starter kit to dockerize a Business Intelligence Project.