Changing MAC address

I have a container that I need to change the MAC address to a static one due to application licensing.

I know docker --mac-address="" will work, but how do I make it work during the image creation with packer?

I have the following process for my centos:7 image:

  1. download some dependencies (net-tools)
  2. change mac address
  3. add local license file based on MAC addess
  4. all done

I have tried setting
“builders”: [
“type”: “docker”,
“image”: “{{user base-image}}”,
“commit”: true,
“changes”: [
“ENV mac-address=‘52:54:00:ad:f4:73’”,
“ENV LSHOST localhost”

That does not work.

I have also tried to manually change it with a script before I load the license but I get:

docker: SIOCSIFFLAGS: Operation not permitted

I guess can this even be done and if so how.

I figured it out, in the changes sections add the following.

“run_command”:["-d", “-i”, “-t”, “–mac-address=11:22:33:44:55:55”, “{{.Image}}”]