从Docker容器内部访问主机详细信息 [英] Access host machine details from inside Docker container

查看:245
本文介绍了从Docker容器内部访问主机详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道从Docker容器中获取主机详细信息(尤其是MAC地址)的方法.

I would like to know the way to get host machine details especially the MAC address from inside Docker container.

推荐答案

也许您可以采用不同的方法来解决此问题.例如.通过环境变量将所需的信息从主机传递到容器.

Maybe you can approach this problem different way. Eg. pass information you need from host to container via environment variables.

docker run -e HOST_MAC=$(ifconfig -a | grep -Po 'HWaddr \K.*$') image

这需要您更改容器的运行方式,但这可能是解决此问题的最干净的方法.

This requires you to change how you run a container, however it's probably the cleanest method of solving this.

这篇关于从Docker容器内部访问主机详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆