search

Home  >  Q&A  >  body text

Can I access the AWS Fargate task ID from inside a Docker container?

I am running a PHP application in a Docker container and I would like the task ID to be included in the stream ID used in the logs sent to AWS Cloudwatch. How can I access it?

From my logs I can see that some of the errors include the system context which contains hopefully something like ECS_CONTAINER_METADATA_URI_V4 which includes the task id but this has to be parsed so hopefully there is a more Clean methods such as ENV[SOME_ENV_VAR] may be referenced in the configuration file.

P粉446800329P粉446800329262 days ago481

reply all(1)I'll reply

  • P粉439804514

    P粉4398045142024-03-31 11:35:45

    You must make a request to the URI at ECS_CONTAINER_METADATA_URI_V4 and parse the response. There is no other way to access this data from inside the container.

    reply
    0
  • Cancelreply