Create a Docker Image
https://timhieuvedocker.blogspot.com/2020/11/dockerizing-nodejs-web-app.html
Push your image to Amazon Elastic Container Registry
Amazon ECR is a managed AWS Docker registry service. Customers can use the familiar Docker CLI to push, pull, and manage images. For Amazon ECR product details, featured customer case studies, and FAQs, see the Amazon Elastic Container Registry product detail pages
This section requires the following:
You have the AWS CLI installed and configured. If you do not have the AWS CLI installed on your system, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide.
Your user has the required IAM permissions to access the Amazon ECR service. For more information, see Amazon ECR Managed Policies.
To tag your image and push it to Amazon ECR
Create an Amazon ECR repository to store your
nodejs-docker-webapp
image. Note therepositoryUri
in the output.aws ecr create-repository --repository-name nodejs-docker-webapp --region
region
Output:
{ "repository": { "registryId": "
aws_account_id
", "repositoryName": "nodejs-docker-webapp", "repositoryArn": "arn:aws:ecr:region
:aws_account_id
:repository/nodejs-docker-webapp", "createdAt": 1505337806.0, "repositoryUri": "aws_account_id
.dkr.ecr.region
.amazonaws.com/nodejs-docker-webapp" } }Tag the
nodejs-docker-webapp
image with therepositoryUri
value from the previous step.docker tag nodejs-docker-webapp
aws_account_id
.dkr.ecr.region
.amazonaws.com/nodejs-docker-webapp
Run the aws ecr get-login-password command (only apply for AWS CLI version 2). Specify the registry URI you want to authenticate to. For more information, see Registry Authentication in the Amazon Elastic Container Registry User Guide.
aws ecr get-login-password | docker login --username AWS --password-stdin
.dkr.ecr.aws_account_id
region
.amazonaws.comPush the image to Amazon ECR with the
repositoryUri
value from the earlier step.docker push
nodejs-docker-webappaws_account_id
.dkr.ecr.region
.amazonaws.com/
Clean up
When you are done experimenting with your Amazon ECR image, you can delete the repository so you are not charged for image storage.
aws ecr delete-repository --repository-name nodejs-docker-webapp --region region
--force
No comments:
Post a Comment