简体   繁体   English

将 Docker 图像从 S3 上传到 ECR

[英]Uploading a Docker Image to ECR from S3

Right now I am creating an application which a user needs to be able to upload a docker image that can be eventually run on ECS.现在我正在创建一个应用程序,用户需要能够上传最终可以在 ECS 上运行的 docker 图像。 Ideally I would like the user to have a presigned url where they can upload to ECR, but this doesn't seem possible.理想情况下,我希望用户有一个预签名的 url,他们可以在其中上传到 ECR,但这似乎不可能。

As a work around to this I was going to have a user upload their docker image to s3 using a presigned url and then try make something that can upload this image on s3 to ECR.作为解决此问题的方法,我打算让用户使用预签名的 url 将他们的 docker 图像上传到 s3,然后尝试制作可以将 s3 上的此图像上传到 ECR 的东西。 Does anyone have a suggestion on how I can take this docker image on s3 and move it to ECR, or another approach to where a user can upload a docker image to ecr directly.有没有人建议我如何在 s3 上拍摄这张 docker 图像并将其移动到 ECR,或者用户可以将 docker 图像直接上传到 ecr 的另一种方法。

Thanks I am new to ECS and ECR so any advice would be appreciated.谢谢我是 ECS 和 ECR 的新手,所以任何建议都将不胜感激。

The first thing you need to understand is that a Docker image is not a single file.您需要了解的第一件事是 Docker 图像不是单个文件。 It is a collection of files (along with a manifest) that hold the different layers of the filesystem.它是包含文件系统不同层的文件(连同清单)的集合。 Different images can (and usually do) share the same layers.不同的图像可以(并且通常)共享相同的层。 The Docker registry (ie, ECR) manages these layers as individual files, and serves them to the Docker daemon (ie, ECS) as needed. Docker 注册表(即 ECR)将这些层作为单独的文件进行管理,并根据需要将它们提供给 Docker 守护程序(即 ECS)。

Ideally I would like the user to have a presigned url where they can upload to ECR理想情况下,我希望用户拥有一个预签名的 url,他们可以在其中上传到 ECR

Assuming that the user has a Docker daemon running (which they must, in order to build a Docker image), you can provide them with a login token that allow them to do a docker push to ECR.假设用户有一个 Docker 守护进程在运行(他们必须这样做,以便构建一个 Docker 图像),您可以为他们提供一个登录令牌,允许他们执行docker push送到 ECR。 You probably already do this:你可能已经这样做了:

aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com

If you want to do this programmatically, you would call the GetAuthorizationToken API. The token that you get will be valid for 12 hours (unfortunately, no way to increase or decrease).如果您想以编程方式执行此操作,您可以调用GetAuthorizationToken API。您获得的令牌有效期为 12 小时(不幸的是,无法增加或减少)。

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

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