Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Getting Mac address from Docker Container

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

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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

or inside the container:

ifconfig -a

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 
about 4 years ago · Santiago Trujillo Report

0

Use docker inspect to pull MacAddress and redirect the results to a file. For example, try this on a container named my-container. This uses range (from the Go template package) to find MacAddress:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' my-container > /path/file.txt

If that doesn't work, first try viewing the metadata available for my-container:

docker inspect my-container

Find MacAddress in those results. Then create a docker inspect command that uses the docker json template function to pull the value from that specific json path. The path to MacAddress may vary, so here's an example that instead uses Status:

docker inspect -f "{{json .State.Health.Status}}" my-container > /path/file.txt
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!