简体   繁体   English

使用 CLI 在 AWS 中构建一个 docker 图像

[英]building a docker image in AWS with CLI

I was using gcloud before and could build a docker image on a GCP machine as follows:我之前使用的是gcloud ,可以在 GCP 机器上构建一个 docker 图像,如下所示:

gcloud builds submit ./my-docker-dir/ -t eu.gcr.io/<path>/<component>:<tag> --timeout 30m --machine-type e2-highcpu-32\n

Is there a similar AWS equivalent?是否有类似的 AWS 等价物?

No, there's no such alternative.不,没有这样的选择。 With AWS you use docker to build & push to ECR.使用 AWS,您可以使用docker buildpush送到 ECR。

An example workflow would be:一个示例工作流程是:

  1. Create a docker file and build it with:创建一个docker文件并使用以下命令构建它:
docker build -t hello-world .
  1. Authenticate your Docker client to the Amazon ECR registry to which you intend to push your image.将您的 Docker 客户端验证到您打算将图像推送到的 Amazon ECR 注册表。
aws ecr get-login-password --region region | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com
  1. Create an ECR repository创建 ECR 存储库
aws ecr create-repository \
    --repository-name hello-world \
    --image-scanning-configuration scanOnPush=true \
    --region region
  1. Tag the docker image you've built.标记您构建的 docker 图像。
docker tag hello-world:latest aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest
  1. Push it to your ECR repo.将其推送到您的 ECR 存储库。
docker push aws_account_id.dkr.ecr.region.amazonaws.com/hello-world:latest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM