← 返回命令列表

Linux command

aws-ecs 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List all ECS clusters

aws ecs list-clusters

List services

aws ecs list-services --cluster [cluster_name]

Describe a service

aws ecs describe-services --cluster [cluster_name] --services [service_name]

List running tasks

aws ecs list-tasks --cluster [cluster_name]

Run a new task

aws ecs run-task --cluster [cluster_name] --task-definition [task_def:revision]

Update a service

aws ecs update-service --cluster [cluster_name] --service [service_name] --force-new-deployment

Execute a command

aws ecs execute-command --cluster [cluster_name] --task [task_id] --container [container_name] --interactive --command "/bin/sh"

Stop a running task

aws ecs stop-task --cluster [cluster_name] --task [task_arn]

说明

aws ecs is a subcommand of the AWS CLI that manages Amazon Elastic Container Service, a fully managed container orchestration service. ECS runs Docker containers on a cluster of EC2 instances or serverless with Fargate. The core concepts are: clusters (logical grouping of resources), task definitions (blueprints for containers), tasks (running instances of task definitions), and services (maintain desired count of tasks). ECS integrates with load balancers, auto scaling, and IAM for production workloads. ECS Exec enables interactive shell access to running containers for debugging, similar to docker exec but through the SSM agent.

参数

list-clusters
List all ECS clusters in the region.
describe-clusters
Get detailed information about clusters.
create-cluster
Create a new ECS cluster.
delete-cluster
Remove an empty cluster.
list-services
List services running in a cluster.
describe-services
Get service details, deployments, and events.
create-service
Create a new service.
update-service
Modify service configuration or trigger deployment.
delete-service
Remove a service from the cluster.
list-tasks
List tasks in a cluster or service.
describe-tasks
Get task details and container status.
run-task
Start a standalone task.
stop-task
Terminate a running task.
execute-command
Run interactive command in a container.
register-task-definition
Create a new task definition revision.
deregister-task-definition
Deregister a task definition revision.
list-task-definitions
List registered task definition families or revisions.
describe-task-definition
Get full details of a task definition.
tag-resource
Add tags to an ECS resource.
wait
Wait until a condition is met (e.g., services-stable, tasks-stopped).
--cluster _name_
Target cluster name or ARN.
--service _name_
Target service name or ARN.
--task-definition _name:revision_
Task definition family and revision.
--desired-count _number_
Number of task instances to run.

FAQ

What is the aws-ecs command used for?

aws ecs is a subcommand of the AWS CLI that manages Amazon Elastic Container Service, a fully managed container orchestration service. ECS runs Docker containers on a cluster of EC2 instances or serverless with Fargate. The core concepts are: clusters (logical grouping of resources), task definitions (blueprints for containers), tasks (running instances of task definitions), and services (maintain desired count of tasks). ECS integrates with load balancers, auto scaling, and IAM for production workloads. ECS Exec enables interactive shell access to running containers for debugging, similar to docker exec but through the SSM agent.

How do I run a basic aws-ecs example?

Run `aws ecs list-clusters` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does list-clusters do in aws-ecs?

List all ECS clusters in the region.