![](/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.