How to access host IP from inside of the docker container?

Expected behavior

Wanted to get the host IP(which is my EC2 instance) from inside of the docker container. I am running a python program inside the container of docker where am using socket library to get the private IP of the machine which ends up picking up the docker container’s IP which I don’t want. What I want is the EC2 instance’s IP but without using curl http://169.254.169.254/latest/meta-data/local-ipv4

Actual behavior

Want to get the host IP

Additional Information

Is there any way I can do that ?

Hello,
Are you find docker ip?
If yes then Use docker inspect
Then You got a docker ip

if you know the hostname of the host, how about the “nslookup” command to get the real ip of the host?

in debian container, apt-get update && apt-get install dnsutils

after install the dnsutils tools, you can try the nslookup command