I would like to know the way to get host machine details especially the MAC address from inside Docker container.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
It will depend on your host system, since you didn't give any information I'm just going to assume CentOS
In this article it shows how you can get that info from /prove on the host system. So, if you mount /prove into your container you should be able to read the right file and pull out your info.
This doesn't seem secure though, and I recommend against it.
One other way is to use
--net=host
while starting the container.$# ifconfig -a | grep -Po 'HWaddr \K.*$'
$# docker run --net=host -it ubuntu:14.04 bash
$# ifconfig -a | grep -Po 'HWaddr \K.*$'
Maybe you can approach this problem different way. Eg. pass information you need from host to container via environment variables.
This requires you to change how you run a container, however it's probably the cleanest method of solving this.
You have many options.
Аnother option is