title: Run docker in background under Powershell
body: <p>Simple question, I want to run docker command in background.<br>
  (Actually running any command with command line parameters under Powershell is my real question, but <code>docker</code> is a simple concrete one)</p>
  
  <p>I have a command</p>
  
  <pre><code>docker run -ti --rm -e DISPLAY=$DISPLAY firefox
  </code></pre>
  
  <p>which runs fine under Powershell, but it blocks. </p>
  
  <p>I want to runs the equivalent method of doing "&amp;" as under *nix:</p>
  
  <pre><code>docker run -ti --rm -e DISPLAY=$DISPLAY firefox &amp;
  </code></pre>
  
  <p>I've tried</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/42222004/">Run exe in background</a></li>
  <li><a href="https://stackoverflow.com/questions/185575">Powershell equivalent of bash ampersand (&amp;) for forking/running background processes</a></li>
  </ul>
  
  <p>but neither works for me:</p>
  
  <pre><code>&gt; ping google.com &amp;
  At line:1 char:17
  + ping google.com &amp;
  +                 ~
  The ampersand (&amp;) character is not allowed.
  
  &gt; Start-Process "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run -ti --rm -e DISPLAY=$DISPLAY firefox
  Start-Process : Parameter cannot be processed because the parameter name 'e' is ambiguous. Possible
  matches include: -ErrorAction -ErrorVariable.
  At line:1 char:86
  + ... Files\Docker\Docker\resources\bin\docker.exe" run -ti --rm -e DISPLAY ...
  +                                                                ~~
      + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
      + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.StartProcessCommand
  
  </code></pre>
  
  <p>Tried to wrap the whole command within <code>Start-Process { ... }</code> doesn't work either. </p>
  
  <p><strong>[UPDATE/Summary]</strong></p>
  
  <p>The accepted answers works (after I removed "<code>-ti</code>" from the command line), as @nischay goyal has put, <em>"please don't use -it as it opens the terminal and blocks it."</em>. The error I got was:</p>
  
  <pre><code>the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
      + CategoryInfo          : NotSpecified: (the input devic...d with 'winpty':String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
      + PSComputerName        : localhost
  </code></pre>
  
  <ul>
  <li><p>So <code>Start-Job</code> <em>might</em> not fit as a general purpose way of doing "<code>&amp;</code>", e.g., if I want to start <code>bash &amp;</code> that way. </p></li>
  <li><p>However, the <code>Start-Process</code> works after passing all the rest of <code>docker</code> command line parameters to the <code>-ArgumentList</code> parameter as a single string.</p></li>
  <li><p>And of course, like all docker/Linux camp people say, use <code>-d</code>. </p></li>
  </ul>
  
  <p>All in all, there are many ways to solve the problem. Pick the one that suits you. </p>