Running Python scripts/APIs on ECS

0

I have multiple Python scripts within a Docker image, each with its input parameters, and I intend to execute them as needed on Amazon Elastic Container Service (ECS).

I have the following scripts inside the docker image:

  • extract_satellite_data.py
  • calculates_ndvi.py

The scripts above require variable input parameters, such as 'sensor' (e.g., 'sentinel2') and 'config_file' (which is a YAML file containing start and end dates, among other things).

Is it possible to define ECS task definitions for each Python script above from the same Docker image and run with the required command-line arguments?

已提问 8 个月前1050 查看次数
2 回答
1
已接受的回答

Before start the questions I'd like to comment first about this sentence that you shared:

multiple Python scripts within a Docker image

From Docker documentation: avoid one container being responsible for multiple aspects of your overall application. That said, I'd work to improve this and have different images for each script (thinking that each script will be the main container process).

Doing the above will facilitate a lot your life for the other tasks. Since you'll have 2 containers (one for each script), you should be able to pass the environment variables using the Task Definition Environments and copying the configuration file (YAML) while building the image.

Hope this helps you!

profile pictureAWS
已回答 8 个月前
1

Hello.

In the ECS task definition, "entryPoint" and "command" are the values for setting up script execution.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/task_definition_parameters.html#container_definitions

profile picture
专家
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则