本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
ecs-cli compose start
从通过复合文件创建的任务定义启动单个 Amazon ECS 任务。
所介绍的某些功能仅可用于最新版本的 ECS CLI。要获取最新版本,请参阅安装 Amazon ECS CLI。
语法
ecs-cli compose start [--region region
]
[--cluster-config cluster_config_name
] [--ecs-profile
ecs_profile
] [--aws-profile
aws_profile
] [--cluster
cluster_name
] [--launch-type
launch_type
] [--create-log-groups]
[--help]
选项
名称 |
描述 |
---|---|
|
指定要使用的 AWS 区域。默认为使用 configure 命令配置的集群。 类型:字符串 必需:否 |
|
指定要使用的 Amazon ECS 集群配置的名称。默认为作为默认值设置的集群设置。 类型:字符串 必需:否 |
|
指定要使用的 Amazon ECS 配置文件的名称。默认为使用 configure profile 命令配置的配置文件。 类型:字符串 必需:否 |
|
指定要使用的 AWS 配置文件。使您能够使用 类型:字符串 必需:否 |
|
指定要使用的 Amazon ECS 集群名称。默认为使用 configure 命令配置的集群。 类型:字符串 必需:否 |
--launch-type
|
指定要使用的启动类型。可用的选项有 FARGATE 或 EC2 。有关启动类型的更多信息,请参阅 Amazon ECS 启动类型。
这将覆盖在集群配置中存储的默认启动类型。 类型:字符串 必需:否 |
|
创建您的 Compose 文件中指定的 CloudWatch 日志组。 必需:否 |
|
显示指定命令的帮助文本。 必需:否 |
示例
运行任务
此示例从 hello-world.yml
复合文件创建一个任务定义。将为 Fargate 启动类型的任务网络配置指定其他 ECS 参数。然后,将会使用该任务定义运行单个任务。
名为 hello-world.yml
的示例 Docker 复合文件:
version: '3' services: nginx: image: nginx:latest ports: - "80:80" logging: driver: awslogs options: awslogs-group:
tutorial
awslogs-region:us-east-1
awslogs-stream-prefix:nginx
名为 ecs-params.yml
的示例 ECS 参数文件:
version: 1 task_definition: task_execution_role:
ecsTaskExecutionRole
ecs_network_mode: awsvpc task_size: mem_limit:0.5GB
cpu_limit:256
run_params: network_configuration: awsvpc_configuration: subnets: -subnet-abcd1234
-subnet-dbca4321
security_groups: -sg-abcd1234
assign_public_ip: ENABLED
命令:
ecs-cli compose --file
hello-world.yml
--ecs-paramsecs-params.yml
start --launch-typeFARGATE
--create-log-groups
输出:
INFO[0000] Using ECS task definition TaskDefinition=ecscompose-hello-world:5