![](/img/trans.png)
[英]Is there any way to get the EC2 instance ip from docker container?
[英]How to get EC2 instance private IP in a private subnet?
我正在使用私有子網中的 Beanstalk 在 docker 容器內運行 python 應用程序,並且我想獲取 EC2 實例的私有/本地 IP。 Is it possible to get the Local IP address without using curl http://169.254.169.254/latest/meta-data/local-ipv4
inside a docker container.
盡管我嘗試docker run --net=host <image_name>
但仍然無法訪問。
您可以使用以下命令獲取 Linux 實例的本地 ip:
hostname -I | awk '{print $1}'
對於 EB,使用.ebexentions 並在 script_name.config 中編寫 bash 腳本以運行: export HOST_IP=$(hostname -I | awk '{print $1}')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.