title: Exit Code 125 from Docker when Trying to Run Container Programmatically
body: <p>I am trying to get an integration test working. In the test initialization phase I attempt to spin up a Redis server from a docker image.</p>
  
  <pre><code>var p = new Process { StartInfo = new ProcessStartInfo("docker", "run --name redistest –p 6379:6379 redis")};
  p.Start();
  </code></pre>
  
  <p>When I do that the process exits with exit code <strong>125</strong>. If I comment out those lines, hit a breakpoint in the test before the test code executes and instead run from the command line </p>
  
  <pre><code>docker run --name redistest -p 6379:6379 redis
  </code></pre>
  
  <p>the test runs as expected when continuing from the breakpoint. The <strong>125</strong> exist code just means <code>docker run</code> failed, so there's not much more information to go on.</p>
  
  <p>Prior to either the command line invocation or the C# invocation, I made sure there was no container named <code>redistest</code> with</p>
  
  <pre><code>docker stop redistest
  docker rm redistest
  </code></pre>
  
  <p>Yet the difference in behavior remains. All of these attempts to run docker programmatically fail:</p>
  
  <ul>
  <li>adding <code>-d</code></li>
  <li>running as a normal user</li>
  <li>running with elevated privileges</li>
  <li>running from within a test</li>
  <li>running from a .NET Framework console app</li>
  </ul>
  
  <p>Why does programmatic process creation of the <code>docker run</code> command cause docker to exit with a 125?</p>
  
  <p>It works programmatically just fine for some images but not others.</p>