I noticed same problem on ECS containers after enabling IMDSv2 on account level.
As per docs you should specify metadata hop limit to 2:
On the Manage IMDS defaults page, do the following:
- For Instance metadata service, choose Enabled.
- For Metadata version, choose V2 only (token required).
- For Metadata response hop limit, specify 2 if your instances will host containers.
See also this question: Using IMDS (v2) with token inside docker on EC2 or ECS