Merge pull request #248 from mpalmer/stable-mac-address-take-2
[discourse_docker.git] / launcher
index 6eb11687af4018038b58fef634bc797b56f653bd..88d174d0098b5076a1219bb21047be4bae39d295 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -448,9 +448,12 @@ run_start() {
      # docker added more hostname rules
      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