Amazon-ecs-agent: Add support for `--init`

Created on 20 Jun 2017  路  18Comments  路  Source: aws/amazon-ecs-agent

Specify an init process
You can use the --init flag to indicate that an init process should be used as the PID 1 in the container. Specifying an init process ensures the usual responsibilities of an init system, such as reaping zombie processes, are performed inside the created container.

The default init process used is the first docker-init executable found in the system path of the Docker daemon process. This docker-init binary, included in the default installation, is backed by tini.

https://docs.docker.com/engine/reference/run/#specify-an-init-process

kinfeature request scopECS Service scopTask Definition

Most helpful comment

You can now specify the --init flag in your task definition. You can add this new option in the AWS Console now, and it'll be available in the AWS CLI and SDKs soon. --init requires at least Docker 1.13.0 and ECS agent v1.15.0.

All 18 comments

Hi @MrSaints. Just want to make sure we understand what you need here. You're just looking to ensure that exited processes get reaped by an init process, right? This will require some work on the ECS API in addition to the agent, and I want to make sure we properly capture use cases so we can assign an appropriate priority to that work. Thanks.

@nmeyerhans We currently run an ECS task that contains a process that spins other processes up. When those processes exit, they may not exit nicely. And consequently, they remain as zombie processes. Before, we would simply use something like dumb-init, and tini. But now, the latter is included in Docker, and can be used via the --init flag. Essentially, what we want is to run our process (within a Docker container) under a PID1 init process, so that signals, and processes are properly handled.

I'm happy to help with this if you can point me in the right direction. Otherwise, I'd love if this is available out-of-the-box. For now, we just installed tini in the Docker image.

With the upgrade to 17.03.1-ce this should be supported OOTB if the agent simply passes --init to docker run right?

@stefansedich I believe so.

@nmeyerhans was having a look into doing this as felt like something I could sink my teeth into, but I assume the API work is something that cannot be done from someone external? originally I thought it was going to be easy to add but then realized what you might have meant when you said "work on the ECS API" is something outside of the scope of the agent.

As expressed on #865, our organisation would also like to use this Docker feature.

is there any way to pass --init flag with ecs agent when dockers run in ec2?

Any movement on this one?

+1

Any updates yet as to how long this one might be? will help me decide if I use the init wrapper in all of our containers or just wait for the support to be added which I would prefer

@stefansedich and others: yes, this is something that is going to be supported soon. I don't have specific details on timing, but we have started work on the backend support.

Thanks for the update @nmeyerhans I look forward to it!

unrelated, but why can't there just be an ECS variable that's like "just pass these flags to docker run" so we don't have to open tickets for every command line flag people want but have to wait forever to get implemented in ECS?

ECS_DOCKER_RUN_FLAGS

Anyway, +1 to --init.

+1

+1

You can now specify the --init flag in your task definition. You can add this new option in the AWS Console now, and it'll be available in the AWS CLI and SDKs soon. --init requires at least Docker 1.13.0 and ECS agent v1.15.0.

Thanks @samuelkarp and team!

Since I had to really struggle to find the relevant info on how to use it:

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

Search for initProcessEnabled

Was this page helpful?
0 / 5 - 0 ratings