简体   繁体   English

如何在AWS的Docker容器中查找正在运行的进程的状态?

[英]How to find the status of a running process inside docker container in AWS?

I have an application (a task) running in containers in AWS. 我有一个应用程序(任务)在AWS的容器中运行。 I need to know its current state and also need to make sure it runs without the container exiting and killing it while in progress. 我需要知道它的当前状态,还需要确保它在不退出容器的情况下运行并杀死它。
It's a C++ binary. 这是C ++二进制文件。

  1. Service - Creating a service will ensure that its fail-safe but how can I read this information from the outside. 服务-创建服务将确保其故障安全,但是我该如何从外部读取此信息。 I could exit the application with a proper exit code but the service will just recreate the task again and again in this manner which is a burden. 我可以使用适当的退出代码退出应用程序,但是服务将以这种方式一次又一次地重新创建任务,这是一个负担。

Is there a recommended way to communicate from the process within an ECS container to know what it is doing at the moment? 是否有建议的方法可以通过ECS容器中的流程进行通信以了解其当前在做什么?

There can be two ways to view ECS container logs: 有两种方法可以查看ECS容器日志:

  1. SSH into your EC2 instance created by ECS, run docker ps to find container ids and docker logs container_id to see what is going on in the container. SSH到由ECS创建的EC2实例中,运行docker ps来查找容器ID,并运行docker logs container_id以查看docker logs container_id中正在发生什么。 (This will not work if you have created your cluster using Fargate as it does not creates EC2 instance, it only creates a network interface) (如果您使用Fargate创建集群,则该方法将不起作用,因为它不会创建EC2实例,它只会创建网络接口)

  2. Configure Cloudwatch on AWS to view container activities. 在AWS上配置Cloudwatch以查看容器活动。 To configure logs you have to create a new version of your task defenition > open container > under storage and logging uncheck auto configure CloudWatch logs > select log driver as awslogs > tag your group, region and prefix keys. 要配置日志,您必须创建新版本的任务定义>打开容器>在存储和日志记录下,取消选中自动配置CloudWatch日志 >选择日志驱动程序为awslogs>标记组,区域和前缀键。 To view your logs, click on the Task tab in your cluster > open your task > expand your container > bottom section shows Log Configuration with a link to your container logs. 要查看日志,请单击集群中的“任务”选项卡>打开任务>展开容器>底部显示“日志配置”,并带有指向容器日志的链接。

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

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