简体   繁体   English

Docker 在 AWS ECS 中运行

[英]Docker run in AWS ECS

I have a command that I am currently running from my OS to run a docker container that takes in a file as an argument and returns some output.我有一个命令,我目前正在从我的操作系统运行一个 docker 容器,该容器将文件作为参数并返回一些 output。

docker run --rm -v ${pwd}:/dir IMAGE [COMMAND] [ARGS]

This allows me to run this container each time i get a new file, obtain output, and spin down the container.这允许我在每次获得新文件时运行此容器,获取 output,然后关闭容器。 I would like to move this to AWS but I'm a bit unsure of how I'd be able to replicate the ad-hoc nature of this command?我想将其移至 AWS,但我有点不确定如何复制此命令的临时性质? Does AWS Support docker run ? AWS Support docker run

So, the short answer is no, you do not have the ability to do this on ECS like how you do normally.因此,简短的回答是否定的,您无法像平时那样在 ECS 上执行此操作。 However, you can build it so you spin up tasks dynamically when a file is uploaded in say S3.但是,您可以构建它,以便在 S3 中上传文件时动态启动任务。

What you want to do is:你想做的是:

S3 Event Notification => EventBridge => StepFunction => ECS RunTask API S3 事件通知 => EventBridge => StepFunction => ECS RunTask API

With a setup like this, you will be able to run a task to process a file each time it's uploaded useful links: https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications-with-amazon-eventbridge/通过这样的设置,您将能够在每次上传有用链接时运行一个任务来处理文件: https://aws.amazon.com/blogs/aws/new-use-amazon-s3-event-notifications -与亚马逊事件桥/

https://aws.amazon.com/blogs/compute/introducing-the-amazon-eventbridge-service-integration-for-aws-step-functions/ https://aws.amazon.com/blogs/compute/introducing-the-amazon-eventbridge-service-integration-for-aws-step-functions/

https://docs.aws.amazon.com/step-functions/latest/dg/connect-ecs.html https://docs.aws.amazon.com/step-functions/latest/dg/connect-ecs.html

There is a gazillion ways you can refactor your application to run on AWS as others have described.正如其他人所描述的那样,您可以通过多种方式重构您的应用程序以在 AWS 上运行。 If you do not want to go down that path perhaps the closest architecture to what you are already doing on your laptop would be to use AWS ECS + the EFS integration (as described in this blog ).如果您不想 go 沿着这条路走下去,那么与您已经在笔记本电脑上所做的最接近的架构可能是使用 AWS ECS + EFS 集成(如本博客所述)。 You can define a task (with a container) that mounts an EFS share.您可以定义一个挂载 EFS 共享的任务(使用容器)。 By populating that EFS share with the file you need will have the container access that file and work on it just like it does locally on your laptop.通过使用您需要的文件填充 EFS 共享,容器将访问该文件并对其进行处理,就像在您的笔记本电脑上进行本地操作一样。

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

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