从Docker容器获取Mac地址 [英] Getting Mac address from Docker Container

查看:848
本文介绍了从Docker容器获取Mac地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从Docker容器获取主机的MAC地址并将其写入文本文件?

Is it possible to get MAC address of the host machine from Docker container and write it in a text file?

推荐答案

docker inspect <container name or id> |grep MacAddress|tr -d ' ,"'|sort -u

或在容器内:

ifconfig -a

ifconfig是'net-tools'linux pkg的一部分,这是进入正在运行的容器的好方法:

ifconfig is part of the 'net-tools' linux pkg and this is good way to enter the running container:

nsenter -t $(docker inspect --format '{{ .State.Pid }}' <container name or id> ) -m -u -i -n -p -w 

这篇关于从Docker容器获取Mac地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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