title: Check if docker container is stopped or failed
body: <p>I am attempting to check if (and handle all edge cases for) a container has been stopped or exited in an unclean state. I am using the <code>'State'</code> block returned by <code>docker inspect &lt;container&gt;</code> to attempt to resolve this.</p>
  
  <pre><code>    "State": {
          "Status": "exited",
          "Running": false,
          "Paused": false,
          "Restarting": false,
          "OOMKilled": false,
          "Dead": false,
          "Pid": 0,
          "ExitCode": 0,
          "Error": "",
          "StartedAt": "2018-03-01T18:56:19.541980678Z",
          "FinishedAt": "2018-03-01T18:56:24.618264625Z"
      },
  </code></pre>
  
  <p>I know the <code>'ExitCode'</code> of a stopped container will be <code>137</code>, but there's a lot of other information there. Will filtering on <code>State.ExitCode == 137</code> be enough to filter for stopped instances?</p>
  
  <p>EDIT: I should mention the reason why I am attempting to do this instead of using <code>pause</code> and <code>unpause</code> to manage my containers is that I want and active/standby arrangement of containers with port bindings. A container in <code>paused</code> state still maintains its port bindings which I need released when it is in <code>standby</code> state.</p>