【问题标题】:How to upload Project+Dockerfile and build on AWS rather than build locally and upload the docker image to ECS?如何上传 Project+Dockerfile 并在 AWS 上构建,而不是在本地构建并将 docker 镜像上传到 ECS?
【发布时间】:2018-09-24 04:35:22
【问题描述】:

由于我的项目 (nodejs) + Dockerfile 非常小 (

作为比较, 在本地构建我的 docker(使用预先下载的 docker 镜像库,即操作系统)并安装 node_modules 大约需要 30 秒。

将构建的 docker 映像 (700mb) 上传到 Amazon ECS 大约需要 10 分钟。

所以我在考虑是否可以将我的项目和 Dockerfile 上传到 AWS,在那里运行构建,我希望他们也能管理中间/基本映像。

我希望花时间只上传比 700mb 小得多的文件 10mb,并运行 docker build 30 秒

【问题讨论】:

  • 我不知道你可以。

标签: amazon-web-services docker dockerfile node-modules


【解决方案1】:

您可以通过两种方式做到这一点

第一个是最好的方法,许多行业标准都遵循,这里也提到了。

https://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-basics.html

第一:

创建小型或微型 t2 实例。分配role to that instance 或您可以configure AWS cli。然后在 EC2 实例中克隆你的项目+dockerfile

因此,与本地系统相比,您的构建过程和推送会更快。

eval $(aws ecr get-login --no-include-email --region us-west-2)
docker build -t hello-world .
docker tag hello-world aws_account_id.dkr.ecr.us-east-1.amazonaws.com/hello-world
docker push aws_account_id.dkr.ecr.us-east-1.amazonaws.com/hello-world

第二次:

在容器实例中克隆您的项目+dockerfile 并在ECS container instance 而不是本地系统中构建您的镜像并将该镜像推送到AWS ECR。如步骤 1 中所述。您需要配置 AWS cli 或最好的方法是将角色分配给您的容器实例。

https://aws.amazon.com/blogs/security/easily-replace-or-attach-an-iam-role-to-an-existing-ec2-instance-by-using-the-ec2-console/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多