title: docker-machine ssh trying to run part of command on local machine
body: <p>When running the following command:</p>
  
  <pre><code>docker-machine ssh name-here "docker swarm init --advertise-addr $(hostname -I | awk '{print $1}')"
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>hostname: illegal option -- I
    usage: hostname [-fs] [name-of-host]</p>
  </blockquote>
  
  <p>This is because the command is attempting to run <code>hostname -I</code> on my local machine, running on MacOS, which doesn't have a <code>-I</code> flag.</p>
  
  <p><em>Attempting to run without double quotes gives the same error.</em></p>
  
  <p>I encapsulated the full command in double quotes so my expectation would be that the full contents of the double quotes is executed as a single argument to <code>docker-machine ssh</code>, but it seems that this is not the case. </p>
  
  <p>I've tried single quotes (<code>'</code>) but this interferes with awk's single quote requirement around the print. I even tried the crazy <code>$$</code> as you would use in makefiles next to the hostname but this doesn't work either.</p>
  
  <p>Why is <code>$(hostname -I | awk '{print $1}')</code> being executed on the host machine when the command is encapsulated in double quotes, and how can I run the above command correctly to initialise a docker swarm with the hostname within the machine?</p>