Docker Community Forums

Share and learn in the Docker community.

Is there a way to get the dynamic assigned MAC addresses of all containers


(Nagendranainar) #1


I am trying to find a way to fetch the IP/MAC address of all containers. Since Docker assigns a unique MAC address for each containers, I am assuming that there might be some table that docker maintains (to maintain the uniqueness).

Can someone please let me know if there is a way to fetch the MAC of all the containers?.


(Bryce Ryan) #2

the output of commands like this

docker container inspect

includes the assigned MAC address. You could iterate through the list of all running containers and list the related field(s). A very basic example on the command line would be

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
1ce3c05b02f0        busybox:uclibc      "tail -f /dev/null"      6 hours ago         Up 6 hours                              config-svc_config-svc.1.pk8uedj6gcg1kbwwa1ed12ghn
$ docker container inspect 1ce3c05b02f0|grep -i mac
            "MacAddress": "",
                    "MacAddress": "02:42:0a:00:00:59",

(Nagendranainar) #3

Hi bryceryan,

Thanks for the response. I noticed that when a container is instantiated using “docker run”, it list the MAC address. but if I use kuberntes, the MAC is not listed.

Is there any way to get the same in kubernetes environment?.