Amazon Elastic Container Service
开发人员指南 (API Version 2014-11-13)
AWS 服务或AWS文档中描述的功能,可能因地区/位置而异。请点击 Amazon AWS 入门,可查看中国地区的具体差异

代理自检诊断

Amazon ECS 代理自检 API 可提供有用的诊断信息。例如,您可以使用代理自检 API 获取任务中的容器的 Docker ID。您可以使用 SSH 连接到容器实例来使用代理自检 API。有关更多信息,请参阅 连接到您的容器实例

以下示例显示了两个任务,一个任务目前正在运行,另一个任务已停止。

注意

以下命令通过 python -mjson.tool 传输以提高可读性。

[ec2-user ~]$ curl http://localhost:51678/v1/tasks | python -mjson.tool

输出:

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1095 100 1095 0 0 117k 0 --:--:-- --:--:-- --:--:-- 133k { "Tasks": [ { "Arn": "arn:aws:ecs:us-west-2:aws_account_id:task/090eff9b-1ce3-4db6-848a-a8d14064fd24", "Containers": [ { "DockerId": "189a8ff4b5f04affe40e5160a5ffadca395136eb5faf4950c57963c06f82c76d", "DockerName": "ecs-console-sample-app-static-6-simple-app-86caf9bcabe3e9c61600", "Name": "simple-app" }, { "DockerId": "f7f1f8a7a245c5da83aa92729bd28c6bcb004d1f6a35409e4207e1d34030e966", "DockerName": "ecs-console-sample-app-static-6-busybox-ce83ce978a87a890ab01", "Name": "busybox" } ], "Family": "console-sample-app-static", "KnownStatus": "STOPPED", "Version": "6" }, { "Arn": "arn:aws:ecs:us-west-2:aws_account_id:task/1810e302-eaea-4da9-a638-097bea534740", "Containers": [ { "DockerId": "dc7240fe892ab233dbbcee5044d95e1456c120dba9a6b56ec513da45c38e3aeb", "DockerName": "ecs-console-sample-app-static-6-simple-app-f0e5859699a7aecfb101", "Name": "simple-app" }, { "DockerId": "096d685fb85a1ff3e021c8254672ab8497e3c13986b9cf005cbae9460b7b901e", "DockerName": "ecs-console-sample-app-static-6-busybox-92e4b8d0ecd0cce69a01", "Name": "busybox" } ], "DesiredStatus": "RUNNING", "Family": "console-sample-app-static", "KnownStatus": "RUNNING", "Version": "6" } ] }

在上面的示例中,已停止的任务 (090eff9b-1ce3-4db6-848a-a8d14064fd24) 具有两个容器。您可以使用 docker inspect container-ID 查看有关每个容器的详细信息。有关更多信息,请参阅 Amazon ECS 容器代理自检