Why does docker not restart on a stack trace? I'm running a container with the following: docker run bot --restart-policy always

However, the container is never actually restarted if it exits due to a stack trace, e.g.,:

Traceback (most recent call last):
  File "/jirabot/source/jbot.py", line 32, in &lt;module&gt;
    rtm = slack_client.rtm_read()
  File "/usr/local/lib/python2.7/site-packages/slackclient/client.py", line 235, in rtm_read
    json_data = self.server.websocket_safe_read()
  File "/usr/local/lib/python2.7/site-packages/slackclient/server.py", line 283, in websocket_safe_read
    data += "{0}\n".format(self.websocket.recv())
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 310, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 327, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 358, in recv_data_frame
    self.pong(frame.data)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 301, in pong
    self.send(payload, ABNF.OPCODE_PONG)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 250, in send
    return self.send_frame(frame)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 275, in send_frame
    l = self._send(data)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 445, in _send
    return send(self.sock, data)
  File "/usr/local/lib/python2.7/site-packages/websocket/_socket.py", line 117, in send
    return sock.send(data)
  File "/usr/local/lib/python2.7/ssl.py", line 707, in send
    v = self._sslobj.write(data)
socket.error: [Errno 32] Broken pipe


What am I missing about the purpose of the restart policy always?
The command line is order sensitive. This command:

docker run bot --restart-policy always


Runs the bot image as a container with the value of CMD set to --restart-policy always. To modify the restart policy of the container being run, you need to pass the option after run and before your image name:

docker run --restart-policy always bot