Merge pull request #248 from mpalmer/stable-mac-address-take-2
authorSam <sam.saffron@gmail.com>
Tue, 3 May 2016 00:48:39 +0000 (10:48 +1000)
committerSam <sam.saffron@gmail.com>
Tue, 3 May 2016 00:48:39 +0000 (10:48 +1000)
Produce random-but-stable MAC addresses, take 2

1  2 
launcher

diff --cc launcher
index 6eb11687af4018038b58fef634bc797b56f653bd,f7152d7b5056cf4f70a800e1eef5d9592e184fa2..88d174d0098b5076a1219bb21047be4bae39d295
+++ b/launcher
@@@ -446,11 -798,14 +446,14 @@@ run_start() 
       # we got to normalize so we only have allowed strings, this is more comprehensive but lets see how bash does first
       # hostname=`$docker_path run $user_args --rm $image ruby -e 'print ARGV[0].gsub(/[^a-zA-Z-]/, "-")' $hostname`
       # docker added more hostname rules
 -     hostname=${hostname/_/-}
 +     hostname=${hostname//_/-}
  
+      mac_address="--mac-address $($docker_path run $user_args -i --rm -a stdout -a stderr $image /bin/sh -c "echo $hostname | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'")"
       set -x
       $docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname" \
-         -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command
+         -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $mac_address $docker_args \
+         $run_image $boot_command
  
     )
     exit 0