awslabs / fargatecli

CLI for AWS Fargate
Apache License 2.0
894 stars 115 forks source link

Question: Support for running multiple containers within a single task? #103

Open holyjak opened 4 years ago

holyjak commented 4 years ago

Is it possible to run multiple containers as a part of a service/task, i.e. the main "service" container and 1 "side-kick" containers such as a nginx proxy? Thank you!

dougtoppin commented 4 years ago

@holyjak I was not able to find a way to add containers to the generated task definition when I added the X-Ray agent to my fargate cli started task. What I did instead was have an entrypoint script run the agent in the background and then the main app in the foreground. That works well for me.

This is what my entrypoint script looks like

#!/bin/sh

# run the x-ray agent in the background and in local mode ( -o  ) to prevent
# the getting container instance metadata error
/usr/bin/xray -t 0.0.0.0:2000 -b 0.0.0.0:2000 -o --config /cfg.yaml &

# run the demo app in the foreground
exec /app.py
holyjak commented 4 years ago

Thank you!

On Mon, 16 Dec 2019, 02:08 Doug Toppin, notifications@github.com wrote:

@holyjak https://github.com/holyjak I was not able to find a way to add containers to the generated task definition when I added the X-Ray agent to my fargate cli started task. What I did instead was have an entrypoint script run the agent in the background and then the main app in the foreground. That works well for me.

This is what my entrypoint script looks like

!/bin/sh

run the x-ray agent in the background and in local mode ( -o ) to prevent

the getting container instance metadata error

/usr/bin/xray -t 0.0.0.0:2000 -b 0.0.0.0:2000 -o --config /cfg.yaml &

run the demo app in the foreground

exec /app.py

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awslabs/fargatecli/issues/103?email_source=notifications&email_token=AAEYSPTZHJZACQQLEA4IBITQY3IJ5A5CNFSM4JC3GS32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG5HOEY#issuecomment-565868307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEYSPV7MVLWBUOSORC6D63QY3IJ5ANCNFSM4JC3GS3Q .

jritsema commented 4 years ago

Our fork (https://github.com/turnerlabs/fargate) doesn't support this either since we haven't had much interest in it. That said, we would consider adding it if there was more demand. For now, we've used terraform to deploy more static type sidecar containers that are really more part of the infrastructure than the application. Here's an example of one that fetches secretsmanager secrets and writes them to a file for the app.

https://github.com/turnerlabs/terraform-ecs-fargate/blob/master/env/dev/secrets-sidecar.tf

dougtoppin commented 4 years ago

The fargate cli seemed to go quiescent a few months ago and I had been wondering if aws cli v2 was going to add fargate specific support such as this. I have found the fg cli to be useful for my personal stuff and have no complaints. The second container need that I had was only that I try to always include x-ray support when I can.