I’ve not used Promtail this way, there is a chance some of the configurations aren’t interchangeable with environment variables. I’d recommend you to read through the documentation again just to double check.
Personally I mount configuration into promtail container directly.
I am not sure how you would get the container-id for Promtail. Perhaps there is a creative solution I am not thinking of. Personally I’ve not found the need to uniquely identify the Promtail container. If you are going to run on ECS, you should run Promtail in DAEMON mode (one count per host), in which case you can uniquely identify the Promtail container through EC2 instance ID.
Sorry for the multiple questions What you mean DAEMON mode? I run ECS with fargate and not EC2 type. I just mount the log folder from my application to promtail in task definition
If you are using fargate then you probably need to do the discovery yourself. Enable container metadata, then you can get the task ID from within the container itself. Then add a script to promtail image and populate the task ID somehow to promtail configuration (populating task ID to an environment variable should work).