简体   繁体   中英

Can I access a AWS Fargate task id from inside a docker container?

I am running a PHP app in a Docker container and I would like to include the task id in the stream id used in the logs I send to AWS Cloudwatch. How can I access that?

From my logs I can see that some errors include system context with promising stuff like ECS_CONTAINER_METADATA_URI_V4 , which includes the task id, but this has to be parsed, so was hoping for a cleaner approach like ENV[SOME_ENV_VAR] that could be referenced in config files.

You have to make a request to the URI at ECS_CONTAINER_METADATA_URI_V4 and parse the response. There isn't another way to access that data from inside the container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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